Browse Source

Merge branch 'release/V1.0.0/test' of http://192.168.4.240:3000/LINK/LINK-SERVER into release/V2.0.0/test

liaoyitao 1 month ago
parent
commit
a11357f6a0

+ 2 - 2
src/main/java/com/lqkj/link/module/zone/controller/ResourceController.java

@@ -276,7 +276,7 @@ public class ResourceController {
276
         String authHeader = request.getHeader("Authorization");
276
         String authHeader = request.getHeader("Authorization");
277
         String userCode = jwtService.decryptUsernameWithHeader(authHeader);
277
         String userCode = jwtService.decryptUsernameWithHeader(authHeader);
278
         Integer userId = userInfoService.detailByUserCode(userCode).getUserId();
278
         Integer userId = userInfoService.detailByUserCode(userCode).getUserId();
279
-        return MessageBean.ok(baseService.ossAddModel(file, "resource/model/" + userId + "/"), "oss上传");
279
+        return MessageBean.ok(baseService.ossAddModel(file, "resource/model/" + request.getLocalAddr() + "/" +  request.getLocalPort() + request.getContextPath() + "/" +  userId + "/"), "oss上传");
280
     }
280
     }
281
 
281
 
282
 
282
 
@@ -289,6 +289,6 @@ public class ResourceController {
289
     public MessageBean<String> ossCheckCapacity(HttpServletRequest request){
289
     public MessageBean<String> ossCheckCapacity(HttpServletRequest request){
290
         String authHeader = request.getHeader("Authorization");
290
         String authHeader = request.getHeader("Authorization");
291
         String userCode = jwtService.decryptUsernameWithHeader(authHeader);
291
         String userCode = jwtService.decryptUsernameWithHeader(authHeader);
292
-        return MessageBean.ok(resourceService.ossCheckCapacity(userCode), "检查容量");
292
+        return MessageBean.ok(resourceService.ossCheckCapacity(userCode, request), "检查容量");
293
     }
293
     }
294
 }
294
 }

+ 3 - 2
src/main/java/com/lqkj/link/module/zone/service/ResourceService.java

@@ -9,6 +9,7 @@ import com.lqkj.link.module.zone.repository.ModelInfoRepository;
9
 import com.lqkj.link.util.AliOSSUtils;
9
 import com.lqkj.link.util.AliOSSUtils;
10
 import com.lqkj.link.util.FileUtils;
10
 import com.lqkj.link.util.FileUtils;
11
 import com.lqkj.link.util.Unzipper;
11
 import com.lqkj.link.util.Unzipper;
12
+import jakarta.servlet.http.HttpServletRequest;
12
 import org.apache.commons.compress.archivers.ArchiveException;
13
 import org.apache.commons.compress.archivers.ArchiveException;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.data.domain.Page;
15
 import org.springframework.data.domain.Page;
@@ -196,9 +197,9 @@ public class ResourceService {
196
      * @param userCode
197
      * @param userCode
197
      * @return
198
      * @return
198
      */
199
      */
199
-    public String ossCheckCapacity(String userCode) {
200
+    public String ossCheckCapacity(String userCode, HttpServletRequest request) {
200
         UserInfo userInfo = userInfoRepository.findByUserCode(userCode);
201
         UserInfo userInfo = userInfoRepository.findByUserCode(userCode);
201
-        Long aLong = aliOSSUtils.ossCheckCapacity("resource/model/" + userInfo.getUserId() + "/");
202
+        Long aLong = aliOSSUtils.ossCheckCapacity("resource/model/" + request.getLocalAddr() + "/" +  request.getLocalPort() + request.getContextPath() + "/" +  userInfo.getUserId() + "/");
202
         return "个人库 已使用" + FileUtils.convertBytes(aLong) + "/20G";
203
         return "个人库 已使用" + FileUtils.convertBytes(aLong) + "/20G";
203
     }
204
     }
204
 }
205
 }

+ 6 - 1
src/main/java/com/lqkj/link/util/AliOSSUtils.java

@@ -44,7 +44,7 @@ public class AliOSSUtils {
44
         String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
44
         String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
45
         //上传文件到 OSS
45
         //上传文件到 OSS
46
         try {
46
         try {
47
-            Thread.sleep(200);
47
+            Thread.sleep(100);
48
         } catch (InterruptedException e) {
48
         } catch (InterruptedException e) {
49
             throw new RuntimeException(e);
49
             throw new RuntimeException(e);
50
         }
50
         }
@@ -68,6 +68,11 @@ public class AliOSSUtils {
68
             String originalFilename = file.getOriginalFilename();
68
             String originalFilename = file.getOriginalFilename();
69
             String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
69
             String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
70
             //上传文件到 OSS
70
             //上传文件到 OSS
71
+            try {
72
+                Thread.sleep(100);
73
+            } catch (InterruptedException e) {
74
+                throw new RuntimeException(e);
75
+            }
71
             OSS ossClient = new OSSClientBuilder().build(aliProperties.getEndpoint(), aliProperties.getAccessKeyId(), aliProperties.getAccessKeySecret());
76
             OSS ossClient = new OSSClientBuilder().build(aliProperties.getEndpoint(), aliProperties.getAccessKeyId(), aliProperties.getAccessKeySecret());
72
             threadPoolUtil.getTaskExecutor().execute(() -> {
77
             threadPoolUtil.getTaskExecutor().execute(() -> {
73
                 ossClient.putObject(aliProperties.getBucketName(), fileName, inputStream);
78
                 ossClient.putObject(aliProperties.getBucketName(), fileName, inputStream);