|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.sunxung.factoring.component.annotation.OperationLog;
|
|
import com.sunxung.factoring.component.annotation.OperationLog;
|
|
import com.sunxung.factoring.component.enums.OperationTypeEnum;
|
|
import com.sunxung.factoring.component.enums.OperationTypeEnum;
|
|
|
|
+import com.sunxung.factoring.component.util.CollectionUtil;
|
|
import com.sunxung.factoring.component.util.FileUtil;
|
|
import com.sunxung.factoring.component.util.FileUtil;
|
|
import com.sunxung.factoring.component.util.StringUtil;
|
|
import com.sunxung.factoring.component.util.StringUtil;
|
|
import com.sunxung.factoring.component.util.onlineConverter.OfficeConverterUtil;
|
|
import com.sunxung.factoring.component.util.onlineConverter.OfficeConverterUtil;
|
|
@@ -12,6 +13,8 @@ import com.sunxung.factoring.component.util.onlineConverter.TextConverterPdfUtil
|
|
import com.sunxung.factoring.dict.impl.FileModuleDict;
|
|
import com.sunxung.factoring.dict.impl.FileModuleDict;
|
|
import com.sunxung.factoring.entity.ResponseJson;
|
|
import com.sunxung.factoring.entity.ResponseJson;
|
|
import com.sunxung.factoring.entity.sys.FileStorage;
|
|
import com.sunxung.factoring.entity.sys.FileStorage;
|
|
|
|
+import com.sunxung.factoring.entity.sys.FileStorageDO;
|
|
|
|
+import com.sunxung.factoring.service.sys.FileService;
|
|
import com.sunxung.factoring.service.sys.FileStorageService;
|
|
import com.sunxung.factoring.service.sys.FileStorageService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.LogManager;
|
|
@@ -52,6 +55,9 @@ public class FileStorageController {
|
|
@Value("${localhost}")
|
|
@Value("${localhost}")
|
|
private String localhost;
|
|
private String localhost;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private FileService fileService;
|
|
|
|
+
|
|
@RequestMapping(value = "/fileStorage/imgUpload")
|
|
@RequestMapping(value = "/fileStorage/imgUpload")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public Map<String, Object> imgUpload(HttpServletRequest req) {
|
|
public Map<String, Object> imgUpload(HttpServletRequest req) {
|
|
@@ -328,9 +334,22 @@ public class FileStorageController {
|
|
@GetMapping("/fileStorage/downloadPdfFile")
|
|
@GetMapping("/fileStorage/downloadPdfFile")
|
|
public void downloadFile(String absolutePath, HttpServletResponse response) {
|
|
public void downloadFile(String absolutePath, HttpServletResponse response) {
|
|
if (absolutePath != null) {
|
|
if (absolutePath != null) {
|
|
|
|
+ String fileName = "下载文件";
|
|
|
|
+ List<FileStorage> fileStorageList = fileStorageService.findByAbsolutePath(absolutePath);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(fileStorageList)){
|
|
|
|
+ fileName = fileStorageList.get(0).getOriginalName();
|
|
|
|
+ }else {
|
|
|
|
+ List<FileStorageDO> fileStorageDOList = fileService.lambdaQuery().eq(FileStorageDO::getAbsolutePath, absolutePath).list();
|
|
|
|
+ if (CollectionUtil.isNotEmpty(fileStorageDOList)){
|
|
|
|
+ fileName = fileStorageDOList.get(0).getOriginalName();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
File file = new File(absolutePath);
|
|
File file = new File(absolutePath);
|
|
- FileUtil.downloadPdfFile(response, file);
|
|
|
|
|
|
+
|
|
|
|
+ FileUtil.downloadPdfFile(response, file, fileName);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|