|
@@ -1,9 +1,12 @@
|
|
package com.example.fms.service.impl;
|
|
package com.example.fms.service.impl;
|
|
|
|
|
|
|
|
+import com.example.fms.common.model.dto.DownloadFileDTO;
|
|
|
|
+import com.example.fms.common.model.dto.DownloadSysFileDTO;
|
|
import com.example.fms.common.model.dto.SystemFileDTO;
|
|
import com.example.fms.common.model.dto.SystemFileDTO;
|
|
import com.example.fms.common.model.vo.ConfigSettingVO;
|
|
import com.example.fms.common.model.vo.ConfigSettingVO;
|
|
import com.example.fms.common.model.vo.SystemFileVO;
|
|
import com.example.fms.common.model.vo.SystemFileVO;
|
|
import com.example.fms.common.utils.ExcuteConfigUtils;
|
|
import com.example.fms.common.utils.ExcuteConfigUtils;
|
|
|
|
+import com.example.fms.common.utils.Response;
|
|
import com.example.fms.domain.SystemFile;
|
|
import com.example.fms.domain.SystemFile;
|
|
import com.example.fms.exception.XiaoShiException;
|
|
import com.example.fms.exception.XiaoShiException;
|
|
import com.example.fms.mapper.SystemFileMapper;
|
|
import com.example.fms.mapper.SystemFileMapper;
|
|
@@ -15,6 +18,7 @@ import com.example.fms.service.SftpService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -59,9 +63,49 @@ public class FileManagerServiceImpl implements IFileManagerService {
|
|
|
|
|
|
//取系统文件
|
|
//取系统文件
|
|
@Override
|
|
@Override
|
|
- public void download(String fileName, String savePath, Integer sourceId){
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ public String download(DownloadFileDTO downloadFileDTO) throws Exception {
|
|
|
|
+ Integer fileId = downloadFileDTO.getFileId();
|
|
|
|
+ String fileName = downloadFileDTO.getFileName();
|
|
|
|
+ Integer sourceId = downloadFileDTO.getSourceId();
|
|
|
|
+ DownloadSysFileDTO downloadSysFileDTO = new DownloadSysFileDTO();
|
|
|
|
+ SystemFileVO systemFileVO = new SystemFileVO();
|
|
|
|
+ if(fileId != null && fileName == null){
|
|
|
|
+ systemFileVO = systemFileService.query(fileId);
|
|
|
|
+ if(systemFileVO.getIsDelete().equals(1)){
|
|
|
|
+ return Response.error("文件已被删除");
|
|
|
|
+ } else {
|
|
|
|
+ BeanUtils.copyProperties(systemFileVO,downloadSysFileDTO);
|
|
|
|
+ downloadSysFileDTO.setSourceId(sourceId);
|
|
|
|
+ fileFactoryService.download(downloadSysFileDTO);
|
|
|
|
+ return Response.success("下载成功");
|
|
|
|
+ }
|
|
|
|
+ } else if(fileId == null && fileName != null) {
|
|
|
|
+ systemFileVO = systemFileMapper.getSystemFile(fileName);
|
|
|
|
+ if(systemFileVO.getIsDelete().equals(1)){
|
|
|
|
+ return Response.error("文件已被删除");
|
|
|
|
+ } else {
|
|
|
|
+ BeanUtils.copyProperties(systemFileVO,downloadSysFileDTO);
|
|
|
|
+ downloadSysFileDTO.setSourceId(sourceId);
|
|
|
|
+ fileFactoryService.download(downloadSysFileDTO);
|
|
|
|
+ return Response.success("下载成功");
|
|
|
|
+ }
|
|
|
|
+ } else if(fileId != null && fileName != null){
|
|
|
|
+ systemFileVO = systemFileService.query(fileId);
|
|
|
|
+ if(fileName.equals(systemFileVO.getFileName())){
|
|
|
|
+ if(systemFileVO.getIsDelete().equals(1)){
|
|
|
|
+ return Response.error("文件已被删除");
|
|
|
|
+ } else {
|
|
|
|
+ BeanUtils.copyProperties(systemFileVO,downloadSysFileDTO);
|
|
|
|
+ downloadSysFileDTO.setSourceId(sourceId);
|
|
|
|
+ fileFactoryService.download(downloadSysFileDTO);
|
|
|
|
+ return Response.success("下载成功");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return Response.error("错误数据");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return Response.error("参数错误");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 删除系统文件
|
|
* 删除系统文件
|