Переглянути джерело

feat: 文件链接返回相对路径,前端拼接完整链接

weijianghai 2 роки тому
батько
коміт
cff963f036

+ 1 - 1
src/main/java/com/nokia/service/AclService.java

@@ -225,7 +225,7 @@ public class AclService {
                         webFunctionSystem.setSystemName(tt.getSystemName());
                         tt.setUrl(tt.getUrl() + (tt.getUrl().contains("?") ? "&" : "?")
                                 + "fromSystem=" + tokenEntity.getFromSystem() + "&token=" + tokenEntity.getToken());
-                        tt.setWebIcon(fileService.getEndpointBucket() + tt.getWebIcon());
+                        tt.setWebIcon(fileService.getBucket() + tt.getWebIcon());
                         webFunctionVos.add(tt);
                     }
                 }

+ 4 - 2
src/main/java/com/nokia/service/file/FileService.java

@@ -71,7 +71,9 @@ public interface FileService {
     }
 
     /**
-     * 获取对象存储服务的地址
+     * 获取存储桶名称
+     *
+     * @return {@link String}
      */
-    String getEndpointBucket();
+    String getBucket();
 }

+ 8 - 5
src/main/java/com/nokia/service/file/MinioServiceImpl.java

@@ -11,6 +11,7 @@ import io.minio.http.Method;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -55,12 +56,12 @@ public class MinioServiceImpl implements FileService {
     @Override
     public String getDownloadUrl(String object, int duration, TimeUnit unit) {
         try {
-            return minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
+            return StringUtils.delete(minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
                     .expiry(duration, unit)
                     .bucket(minioConfig.getBucket())
                     .object(object)
                     .method(Method.GET)
-                    .build());
+                    .build()), minioConfig.getEndpoint());
         } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException |
                  InvalidResponseException | IOException | NoSuchAlgorithmException | XmlParserException |
                  ServerException e) {
@@ -101,10 +102,12 @@ public class MinioServiceImpl implements FileService {
     }
 
     /**
-     * 获取对象存储服务的地址
+     * 获取存储桶名称
+     *
+     * @return {@link String}
      */
     @Override
-    public String getEndpointBucket() {
-        return minioConfig.getEndpoint() + minioConfig.getBucket();
+    public String getBucket() {
+        return minioConfig.getBucket();
     }
 }

+ 1 - 1
src/main/resources/application-product.properties

@@ -22,7 +22,7 @@ springdoc.api-docs.enabled=false
 springdoc.swagger-ui.enabled=false
 knife4j.production=true
 # minio配置
-minio.endpoint=https://192.168.70.125:12041/
+minio.endpoint=http://192.168.10.7:19000/
 minio.bucket=oss-acl-tousu-prod
 minio.accessKey=acl-tousu-prod
 minio.secretKey=CM0E8eHNnDA0FpD2MoaV89wbd12QxJ2V

+ 1 - 1
src/main/resources/application-test.properties

@@ -18,7 +18,7 @@ spring.redis.database=10
 spring.redis.password=Richr00t
 redis.timeoutSeconds=600
 # minio配置
-minio.endpoint=https://192.168.50.3:12041/
+minio.endpoint=http://192.168.10.7:19000/
 minio.bucket=oss-acl-tousu-test
 minio.accessKey=acl-tousu-test
 minio.secretKey=LY6HPgUwc9GXzhU1Rq8wuwNC8Ac07V3a

+ 1 - 1
src/main/resources/application.properties

@@ -1,5 +1,5 @@
 # 启用的配置
-spring.profiles.active=product
+spring.profiles.active=test
 top.url=http://10.17.180.3/prod-api/verifySystem
 dop.url=http://10.17.180.5:8089/prod-api/verifySystem
 woyunwei.url=http://192.168.70.130:13000/PAOOS/aaaa/userservice/getUserInfo.do?method=findUserBySessionID&sessionID=