2 Commits 882e7326c9 ... a11357f6a0

Author SHA1 Message Date
  liaoyitao a11357f6a0 Merge branch 'release/V1.0.0/test' of http://192.168.4.240:3000/LINK/LINK-SERVER into release/V2.0.0/test 1 month ago
  liaoyitao c8e70d7cd7 fix:个人库上传调整 1 month ago

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

@@ -276,7 +276,7 @@ public class ResourceController {
276 276
         String authHeader = request.getHeader("Authorization");
277 277
         String userCode = jwtService.decryptUsernameWithHeader(authHeader);
278 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 289
     public MessageBean<String> ossCheckCapacity(HttpServletRequest request){
290 290
         String authHeader = request.getHeader("Authorization");
291 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 9
 import com.lqkj.link.util.AliOSSUtils;
10 10
 import com.lqkj.link.util.FileUtils;
11 11
 import com.lqkj.link.util.Unzipper;
12
+import jakarta.servlet.http.HttpServletRequest;
12 13
 import org.apache.commons.compress.archivers.ArchiveException;
13 14
 import org.springframework.beans.factory.annotation.Autowired;
14 15
 import org.springframework.data.domain.Page;
@@ -196,9 +197,9 @@ public class ResourceService {
196 197
      * @param userCode
197 198
      * @return
198 199
      */
199
-    public String ossCheckCapacity(String userCode) {
200
+    public String ossCheckCapacity(String userCode, HttpServletRequest request) {
200 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 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 44
         String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
45 45
         //上传文件到 OSS
46 46
         try {
47
-            Thread.sleep(200);
47
+            Thread.sleep(100);
48 48
         } catch (InterruptedException e) {
49 49
             throw new RuntimeException(e);
50 50
         }
@@ -68,6 +68,11 @@ public class AliOSSUtils {
68 68
             String originalFilename = file.getOriginalFilename();
69 69
             String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
70 70
             //上传文件到 OSS
71
+            try {
72
+                Thread.sleep(100);
73
+            } catch (InterruptedException e) {
74
+                throw new RuntimeException(e);
75
+            }
71 76
             OSS ossClient = new OSSClientBuilder().build(aliProperties.getEndpoint(), aliProperties.getAccessKeyId(), aliProperties.getAccessKeySecret());
72 77
             threadPoolUtil.getTaskExecutor().execute(() -> {
73 78
                 ossClient.putObject(aliProperties.getBucketName(), fileName, inputStream);