plf 4 лет назад
Родитель
Сommit
032386f404

+ 19 - 1
src/main/java/com/caimei/www/service/page/impl/DocumentAuthServiceImpl.java

@@ -33,6 +33,8 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -68,6 +70,9 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
     @Value("${aliyun.endpoint}")
     private String endpoint;
 
+    @Value("${spring.profiles.active}")
+    private String active;
+
     @Override
     public Boolean getAuthorizationCookie(String authorizationMobile) {
         if (!StringUtils.isEmpty(authorizationMobile)) {
@@ -198,9 +203,22 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
      */
     private void setOssArchivePdfUrl(OssArchivePdf ossArchivePdf) {
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+        String ossName = ossArchivePdf.getOssName();
         // 设置URL过期时间为1个小时
         Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
-        String url = ossClient.generatePresignedUrl(bucketName, ossArchivePdf.getOssName(), expiration).toString();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = null;
+        try {
+            date = format.parse("2021-06-01 00:00:00");
+            if (ossArchivePdf.getUploadTime() != null && ossArchivePdf.getUploadTime().compareTo(date) > 0) {
+                //之后的文件都放在对应文件夹里
+                ossName = active + "/" + ossName;
+            }
+        } catch (ParseException e) {
+            log.info("格式化时间错误", e);
+        }
+
+        String url = ossClient.generatePresignedUrl(bucketName, ossName, expiration).toString();
         ossArchivePdf.setUrl(url);
         ossClient.shutdown();
     }

+ 1 - 1
src/main/resources/config/beta/application-beta.yml

@@ -67,7 +67,7 @@ fdfs:
 
 http:
   multipart:
-    maxFileSize: 10Mb
+    maxFileSize: 20Mb
     maxRequestSize: 100Mb
 
 #阿里云oss存储

+ 1 - 1
src/main/resources/config/dev/application-dev.yml

@@ -74,7 +74,7 @@ fdfs:
 
 http:
   multipart:
-    maxFileSize: 10Mb
+    maxFileSize: 20Mb
     maxRequestSize: 100Mb
 
 #阿里云oss存储

+ 1 - 1
src/main/resources/config/prod/application-prod.yml

@@ -68,7 +68,7 @@ fdfs:
 
 http:
   multipart:
-    maxFileSize: 10Mb
+    maxFileSize: 20Mb
     maxRequestSize: 100Mb
 
 #阿里云oss存储