From c5475985b9a0d472d8eb349dc0a8599ad767db3a Mon Sep 17 00:00:00 2001 From: "liang.chao" Date: Thu, 14 Mar 2024 09:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=96=99=E7=94=B3=E8=AF=B7=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ScrapApplyDetailsServiceImpl.java | 2 +- .../sgzb/system/service/impl/SysFileServiceImpl.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java index 5d4e04bc..db127df3 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java @@ -72,7 +72,7 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService { @Override public List getFileUrl(String fileIds) { List fileUrlList = new ArrayList<>(); - if (fileIds!=null &&fileIds.isEmpty()){ + if (fileIds != null && !fileIds.isEmpty()) { for (String s : fileIds.split(",")) { String url = scrapApplyDetailsMapper.getFileUrl(s); fileUrlList.add(url); diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysFileServiceImpl.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysFileServiceImpl.java index 225cd82d..1df54485 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysFileServiceImpl.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysFileServiceImpl.java @@ -12,6 +12,7 @@ import org.apache.poi.hwpf.extractor.WordExtractor; import org.apache.poi.openxml4j.util.ZipSecureFile; import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -37,6 +38,11 @@ public class SysFileServiceImpl implements SysFileService { @Resource private FileInfoMapper dao; + /** + * 上传文件存储在本地的根路径 + */ + @Value("${file.path}") + private String localFilePath; /** * 本地文件上传接口 @@ -133,7 +139,7 @@ public class SysFileServiceImpl implements SysFileService { String tmpName = multipartFile.getOriginalFilename(); tmpName = tmpName.substring(tmpName.lastIndexOf("\\") + 1); tmpName = IdUtil.fastSimpleUUID() + System.currentTimeMillis() + tmpName.substring(tmpName.lastIndexOf("."), tmpName.length()); - String imageFiles = "/data/sgzb/" + fileType + "/"; + String imageFiles = localFilePath + fileType + "/"; String os = System.getProperty("os.name"); if (os.toLowerCase().startsWith(GlobalConstants.STRING_WIN)) { imageFiles = "D://files/" + fileType + "/"; @@ -172,7 +178,7 @@ public class SysFileServiceImpl implements SysFileService { String tmpName = multipartFile.getOriginalFilename(); tmpName = tmpName.substring(tmpName.lastIndexOf("\\") + 1); tmpName = IdUtil.fastSimpleUUID() + System.currentTimeMillis() + tmpName.substring(tmpName.lastIndexOf("."), tmpName.length()); - String imageFiles = "/data/sgzb/" + fileType + "/"; + String imageFiles = localFilePath + fileType + "/"; String os = System.getProperty("os.name"); if (os.toLowerCase().startsWith(GlobalConstants.STRING_WIN)) { imageFiles = "D://files/" + fileType + "/";