孟令鑫 1 年間 前
コミット
d2c8827862

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 57 - 0
pom.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.2</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.cicv</groupId>
+    <artifactId>oss-config</artifactId>
+    <version>1.0</version>
+    <name>oss-config</name>
+    <description>oss-config</description>
+    <properties>
+        <java.version>8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <image>
+                        <builder>paketobuildpacks/builder-jammy-base:latest</builder>
+                    </image>
+                    <excludes>
+                        <exclude>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                        </exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
src/main/java/com/cicv/oss/config/OssConfigApplication.java

@@ -0,0 +1,13 @@
+package com.cicv.oss.config;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class OssConfigApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(OssConfigApplication.class, args);
+    }
+
+}

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

@@ -0,0 +1,41 @@
+package com.cicv.oss.config.adapter.controller;
+
+import com.cicv.oss.config.adapter.entity.OssConfigInfo;
+import com.cicv.oss.config.infra.config.OssConfig;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("/algorithm")
+public class OssController {
+    @Resource
+    private OssConfig ossConfig;
+
+    /**
+     * endpoint: "http://open-bucket.oss.icvdc.com"
+     * access-key-id:
+     * access-key-secret:
+     * bucket-name:
+     *
+     * @param token
+     * @return
+     */
+    @GetMapping("/get")
+    public OssConfigInfo get(@RequestParam("token") String token) {
+        if ("nXonLUcMtGcrQqqKiyygIwyVbvizE0wD".equals(token)) {
+            return new OssConfigInfo(
+                    ossConfig.getEndpoint(),
+                    ossConfig.getAccessKeyId(),
+                    ossConfig.getAccessKeySecret(),
+                    ossConfig.getBucketName()
+            );
+        } else {
+            return null;
+        }
+    }
+
+}

+ 17 - 0
src/main/java/com/cicv/oss/config/adapter/entity/OssConfigInfo.java

@@ -0,0 +1,17 @@
+package com.cicv.oss.config.adapter.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OssConfigInfo {
+    private String endpoint;
+    private String accessKeyId;
+    private String accessKeySecret;
+    private String bucketName;
+}

+ 17 - 0
src/main/java/com/cicv/oss/config/infra/config/OssConfig.java

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

+ 9 - 0
src/main/resources/application.yaml

@@ -0,0 +1,9 @@
+
+
+oss:
+  endpoint: "http://open-bucket.oss.icvdc.com"
+  access-key-id: "n8glvFGS25MrLY7j"
+  access-key-secret: "xZ2Fozoarpfw0z28FUhtg8cu0yDc5d"
+  bucket-name: "open-bucket"
+server:
+  port: 18379