home 2 жил өмнө
parent
commit
e7c5f96cb5

+ 5 - 15
hx-service/service-file/src/main/java/com/fjhx/service/impl/FileInfoServiceImpl.java

@@ -41,16 +41,18 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         String fileName = file.getOriginalFilename();
         String fileName = file.getOriginalFilename();
         String suffix = FileUtil.getSuffix(fileName);
         String suffix = FileUtil.getSuffix(fileName);
 
 
-        String path = getFilePath();
+        String rootPath = BladeApplication.isLocalDev() ? "D:/hx/" : "/mnt/file/";
+        String path = DateUtil.format(new Date(), "yyyy-MM/dd/");
         String filePath = path + UUID.randomUUID() + "." + suffix;
         String filePath = path + UUID.randomUUID() + "." + suffix;
 
 
-        FileUtil.mkdir(path);
+        FileUtil.mkdir(rootPath + path);
+
         FileOutputStream fileOutputStream = null;
         FileOutputStream fileOutputStream = null;
         InputStream inputStream = null;
         InputStream inputStream = null;
 
 
         try {
         try {
             inputStream = file.getInputStream();
             inputStream = file.getInputStream();
-            fileOutputStream = new FileOutputStream(filePath);
+            fileOutputStream = new FileOutputStream(rootPath + filePath);
             int index;
             int index;
             byte[] bytes = new byte[1024];
             byte[] bytes = new byte[1024];
 
 
@@ -158,16 +160,4 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         return list.stream().map(item -> BeanUtil.toBean(item, FileInfoParam.class)).collect(Collectors.toList());
         return list.stream().map(item -> BeanUtil.toBean(item, FileInfoParam.class)).collect(Collectors.toList());
     }
     }
 
 
-    /**
-     * 获取文件保存路径
-     *
-     * @return
-     */
-    private String getFilePath() {
-        StringJoiner joiner = new StringJoiner("/");
-        joiner.add(BladeApplication.isLocalDev() ? "D:/hx" : "/mnt/file");
-        joiner.add(DateUtil.format(new Date(), "yyyy-MM/dd/"));
-        return joiner.toString();
-    }
-
 }
 }

+ 1 - 1
hx-service/service-product/src/main/resources/application-dev.yml

@@ -1,6 +1,6 @@
 # 服务器端口
 # 服务器端口
 server:
 server:
-  port: 8400
+  port: 8002
 logging:
 logging:
   level:
   level:
     org.springframework.data.mongodb.core: DEBUG
     org.springframework.data.mongodb.core: DEBUG

+ 1 - 1
hx-service/service-product/src/main/resources/application-prod.yml

@@ -1,6 +1,6 @@
 # 服务器端口
 # 服务器端口
 server:
 server:
-  port: 8400
+  port: 8002
 
 
 # 数据源配置
 # 数据源配置
 spring:
 spring:

+ 1 - 1
hx-service/service-product/src/main/resources/application-test.yml

@@ -1,6 +1,6 @@
 # 服务器端口
 # 服务器端口
 server:
 server:
-  port: 8400
+  port: 8002
 
 
 # 数据源配置
 # 数据源配置
 spring:
 spring: