|
@@ -1,17 +1,28 @@
|
|
|
package com.simuwang.manage.api.file;
|
|
|
|
|
|
import com.simuwang.base.common.support.MybatisPage;
|
|
|
+import com.simuwang.base.common.util.EncodeUtil;
|
|
|
import com.simuwang.base.pojo.dos.FileManageDO;
|
|
|
import com.simuwang.base.pojo.dto.query.FileManagePageQuery;
|
|
|
+import com.simuwang.base.pojo.vo.EmailFileInfoVO;
|
|
|
+import com.simuwang.base.pojo.vo.FileIdVO;
|
|
|
import com.simuwang.base.pojo.vo.FileManageVO;
|
|
|
import com.simuwang.logging.SystemLog;
|
|
|
import com.simuwang.manage.service.FileMangeService;
|
|
|
import com.smppw.common.pojo.ResultVo;
|
|
|
-import org.checkerframework.checker.units.qual.A;
|
|
|
+import jakarta.servlet.ServletOutputStream;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
/**
|
|
|
* FileName: FileManageController
|
|
|
* Author: chenjianhua
|
|
@@ -23,6 +34,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
@RequestMapping("/v1/file-manage")
|
|
|
public class FileManageController {
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(FileManageController.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private FileMangeService fileMangeService;
|
|
|
/**
|
|
@@ -52,4 +65,27 @@ public class FileManageController {
|
|
|
ResultVo vo = fileMangeService.uploadFile(file,fundId, fileType,fileDate);
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件下载
|
|
|
+ * @param fileId
|
|
|
+ * @param response
|
|
|
+ * @param request
|
|
|
+ */
|
|
|
+ @SystemLog(value = "下载文件", type = SystemLog.Type.UPLOAD_OR_IMPORT)
|
|
|
+ @PostMapping("download-file")
|
|
|
+ public void downloadFile(@RequestBody FileIdVO fileId, HttpServletResponse response, HttpServletRequest request){
|
|
|
+ try {
|
|
|
+ FileManageVO fileManageVO = fileMangeService.getFileByFileId(fileId.getFileId());
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + EncodeUtil.encodeUTF8(fileManageVO.getFileName()));
|
|
|
+ ServletOutputStream outputStream = response.getOutputStream();
|
|
|
+ FileUtils.copyFile(new File(fileManageVO.getFilePath()),outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|