LingxinMeng 1 سال پیش
والد
کامیت
61c4563a52

+ 27 - 0
src/main/java/com/cicv/oss/config/adapter/controller/OssController.java

@@ -2,6 +2,8 @@ package com.cicv.oss.config.adapter.controller;
 
 import com.cicv.oss.config.adapter.entity.OssConfigInfo;
 import com.cicv.oss.config.infra.config.OssConfig;
+import com.cicv.oss.config.infra.config.PjiOssConfig;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -14,6 +16,8 @@ import javax.annotation.Resource;
 public class OssController {
     @Resource
     private OssConfig ossConfig;
+    @Resource
+    private PjiOssConfig pjiOssConfig;
 
     /**
      * endpoint: "http://open-bucket.oss.icvdc.com"
@@ -38,5 +42,28 @@ public class OssController {
         }
     }
 
+    /**
+     * endpoint: "http://open-bucket.oss.icvdc.com"
+     * access-key-id:
+     * access-key-secret:
+     * bucket-name:
+     *
+     * @param token
+     * @return
+     */
+    @GetMapping("/pji")
+    public OssConfigInfo pji(@RequestParam("token") String token) {
+        if ("nXonLUcMtGcrQqqKiyygIwyVbvizE0wD".equals(token)) {
+            return new OssConfigInfo(
+                    pjiOssConfig.getEndpoint(),
+                    pjiOssConfig.getAccessKeyId(),
+                    pjiOssConfig.getAccessKeySecret(),
+                    pjiOssConfig.getBucketName()
+            );
+        } else {
+            return null;
+        }
+    }
+
 
 }

+ 15 - 0
src/main/java/com/cicv/oss/config/adapter/entity/PjiOssConfigInfo.java

@@ -0,0 +1,15 @@
+package com.cicv.oss.config.adapter.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PjiOssConfigInfo {
+    private String endpoint;
+    private String accessKeyId;
+    private String accessKeySecret;
+    private String bucketName;
+}

+ 15 - 0
src/main/java/com/cicv/oss/config/infra/config/PjiOssConfig.java

@@ -0,0 +1,15 @@
+package com.cicv.oss.config.infra.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "pji-oss")
+public class PjiOssConfig {
+    private String endpoint;
+    private String accessKeyId;
+    private String accessKeySecret;
+    private String bucketName;
+}

+ 6 - 1
src/main/resources/application.yaml

@@ -1,4 +1,9 @@
-
+pji-oss:
+  endpoint: "http://pji-bucket1.oss.icvdc.com"
+  #  endpoint: "http://1.202.169.136"
+  access-key-id: "n8glvFGS25MrLY7j"
+  access-key-secret: "xZ2Fozoarpfw0z28FUhtg8cu0yDc5d"
+  bucket-name: "pji-bucket1"
 
 oss:
   endpoint: "http://open-bucket.oss.icvdc.com"