chore: 调整项目结构
diff --git a/thirdparty-agent/agent/.gitignore b/thirdparty-agent/agent/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/thirdparty-agent/agent/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/thirdparty-agent/agent/Dockerfile b/thirdparty-agent/agent/Dockerfile
new file mode 100644
index 0000000..f7bf86e
--- /dev/null
+++ b/thirdparty-agent/agent/Dockerfile
@@ -0,0 +1,18 @@
+FROM harbor.supwisdom.com/institute/openjdk:8-jre-alpine
+
+ENV ENABLE_JMX_SSL=false
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=docker
+ENV SPRING_PROFILES_ACTIVE=docker
+
+ARG NAME
+ARG VERSION
+ARG JAR_FILE
+
+LABEL name=$NAME \
+ version=$VERSION
+
+EXPOSE 8080
+
+EXPOSE 8443
+
+COPY --chown=java-app:java-app target/${JAR_FILE} /home/java-app/lib/app.jar
diff --git a/thirdparty-agent/agent/pom.xml b/thirdparty-agent/agent/pom.xml
new file mode 100644
index 0000000..eecf40b
--- /dev/null
+++ b/thirdparty-agent/agent/pom.xml
@@ -0,0 +1,117 @@
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-thirdparty-agent-parent</artifactId>
+ <version>0.0.2-SNAPSHOT</version>
+ </parent>
+
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-thirdparty-agent</artifactId>
+ <version>0.0.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Supwisdom Backend Framework Third Party Agent</name>
+ <description>Supwisdom Backend Framework Third Party Agent project</description>
+
+ <properties>
+ <start-class>com.supwisdom.institute.backend.thirdparty.agent.Application</start-class>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <!-- 微服务 健康监控 -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-thirdparty-poa</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ </dependency>
+
+
+ <!-- 热部署,无需重启项目 -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-devtools</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+</project>
diff --git a/thirdparty-agent/agent/src/main/java/com/supwisdom/institute/backend/thirdparty/agent/Application.java b/thirdparty-agent/agent/src/main/java/com/supwisdom/institute/backend/thirdparty/agent/Application.java
new file mode 100644
index 0000000..089732a
--- /dev/null
+++ b/thirdparty-agent/agent/src/main/java/com/supwisdom/institute/backend/thirdparty/agent/Application.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.thirdparty.agent;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+import com.supwisdom.institute.backend.common.core.transmit.annotation.EnableSimpleUserTransmit;
+import com.supwisdom.institute.backend.common.framework.exception.EnableCustomExceptionHandler;
+
+@SpringBootApplication
+
+@EnableScheduling
+
+@EnableSimpleUserTransmit
+@EnableCustomExceptionHandler
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+ @Bean
+ public CorsFilter corsFilter() {
+ final CorsConfiguration config = new CorsConfiguration();
+ // config.setAllowCredentials(true);
+ config.addAllowedOrigin("*");
+ config.addAllowedHeader("*");
+ config.addAllowedMethod("*");
+
+ final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ source.registerCorsConfiguration("/v2/api-docs", config);
+
+ return new CorsFilter(source);
+ }
+
+}
diff --git a/thirdparty-agent/agent/src/main/java/com/supwisdom/institute/backend/thirdparty/agent/configuration/Swagger2Config.java b/thirdparty-agent/agent/src/main/java/com/supwisdom/institute/backend/thirdparty/agent/configuration/Swagger2Config.java
new file mode 100644
index 0000000..a0a511c
--- /dev/null
+++ b/thirdparty-agent/agent/src/main/java/com/supwisdom/institute/backend/thirdparty/agent/configuration/Swagger2Config.java
@@ -0,0 +1,110 @@
+package com.supwisdom.institute.backend.thirdparty.agent.configuration;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.ApiKey;
+import springfox.documentation.service.AuthorizationScope;
+import springfox.documentation.service.Contact;
+import springfox.documentation.service.SecurityReference;
+import springfox.documentation.service.SecurityScheme;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger.web.UiConfiguration;
+import springfox.documentation.swagger.web.UiConfigurationBuilder;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class Swagger2Config {
+
+ @Value("${swagger2.apis.basePackage:com.supwisdom.institute}")
+ private String basePackage;
+
+ @Bean
+ public Docket createRestApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .securitySchemes(securitySchemes())
+ .securityContexts(securityContexts())
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage(basePackage))
+ .paths(PathSelectors.any())
+ .build()
+ ;
+ }
+
+ private ApiInfo apiInfo() {
+ Contact contact = new Contact("Backend Third Party Agent", "https://sw-backend-agent.supwisdom.com/swagger-ui.html", ""); // name, url, email
+ return new ApiInfoBuilder()
+ .title("Backend Third Party Agent APIs")
+ .description("管理后台 - 代理接口<br /><br />"
+ + "X-FORWARD-USER(测试用):<br /><br />"
+ + "明文:{\"attributes\":{\"accountId\":\"1\"},\"roles\":[\"ROLE_ADMIN\",\"administrator\",\"user\"],\"username\":\"swadmin\"}<br /><br />"
+ + "Base64:eyJhdHRyaWJ1dGVzIjp7ImFjY291bnRJZCI6IjEifSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsImFkbWluaXN0cmF0b3IiLCJ1c2VyIl0sInVzZXJuYW1lIjoic3dhZG1pbiJ9<br /><br />"
+ + "使用 Base64字符串 进行 Authorize,然后进行接口测试<br /><br />"
+ + "若需要其他帐号,请自行拼接明文,再进行 Base64 编码<br /><br />"
+ + ""
+ )
+ .termsOfServiceUrl("http://www.supwisdom.com/")
+ .contact(contact)
+ .version("1.0")
+ .build();
+ }
+
+ private List<SecurityScheme> securitySchemes() {
+ //return newArrayList(new BasicAuth("sample"));
+ return newArrayList(
+ //new BasicAuth("Basic"),
+ //new ApiKey("JWTToken", "Authorization", "header"),
+ new ApiKey("SimpleUserTransmit", "X-FORWARD-USER", "header"));
+ }
+
+ private List<SecurityContext> securityContexts() {
+
+ List<SecurityReference> globalSecurityReference = newArrayList(
+ new SecurityReference("SimpleUserTransmit", new AuthorizationScope[]{new AuthorizationScope("global", "accessEverything")}));
+
+// AuthorizationScope[] authScopes = new AuthorizationScope[1];
+// authScopes[0] = new AuthorizationScopeBuilder()
+// .scope("read")
+// .description("read access")
+// .build();
+// SecurityReference securityReference = SecurityReference.builder()
+// .reference("sample")
+// .scopes(authScopes)
+// .build();
+
+ return newArrayList(
+ SecurityContext.builder()
+ .securityReferences(newArrayList(globalSecurityReference))
+ .build());
+ }
+
+ @Bean
+ UiConfiguration uiConfig() {
+
+ return UiConfigurationBuilder.builder().build();
+
+// return new UiConfiguration(null, // url
+// "none", // docExpansion => none | list
+// "alpha", // apiSorter => alpha
+// "schema", // defaultModelRendering => schema
+// UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS,
+// false, // enableJsonEditor => true || false
+// true, // showRequestHeaders => true | false
+// 60000L); // requestTimeout => in milliseconds, defaults to null
+// // (uses jquery xh timeout)
+ }
+
+}
diff --git a/thirdparty-agent/agent/src/main/resources/application-docker.yml b/thirdparty-agent/agent/src/main/resources/application-docker.yml
new file mode 100644
index 0000000..c48d4b2
--- /dev/null
+++ b/thirdparty-agent/agent/src/main/resources/application-docker.yml
@@ -0,0 +1,63 @@
+server:
+ port: ${SERVER_PORT:8443}
+ ssl:
+ enabled: ${SSL_ENABLED:true}
+ clientAuth: NEED
+ key-store: ${SSL_KEYSTORE_FILE:file:/certs/server/server.keystore}
+ key-store-password: ${SSL_KEYSTORE_PASSWORD:}
+ trust-store: ${SSL_TRUSTSTORE_FILE:file:/certs/server/server.truststore}
+ trust-store-password: ${SSL_TRUSTSTORE_PASSWORD:}
+ tomcat:
+ accesslog:
+ enabled: ${TOMCAT_ACCESSLOG_ENABLED:false}
+ buffered: ${TOMCAT_ACCESSLOG_BUFFERED:true}
+ directory: ${TOMCAT_ACCESSLOG_DIR:log}
+ prefix: ${TOMCAT_ACCESSLOG_PREFIX:sa-api-accesslog}
+ suffix: ${TOMCAT_ACCESSLOG_SUFFIX:.log}
+ file-date-format: ${TOMCAT_ACCESSLOG_FILE_DATE_FORMAT:.yyyy-MM-dd}
+ rotate: ${TOMCAT_ACCESSLOG_ROTATE:true}
+
+
+##
+# logging
+#
+logging:
+ level:
+ root: INFO
+ com.supwisdom: INFO
+
+
+spring:
+ jackson:
+ time-zone: ${JACKSON_TIME_ZONE:Asia/Shanghai}
+
+##
+# spring.redis
+#
+ redis:
+ host: ${SPRING_REDIS_HOST:redis-server}
+ port: ${SPRING_REDIS_PORT:6379}
+ password: ${SPRING_REDIS_PASSWORD:}
+
+
+##
+# online-doc
+#
+infras.online-doc.enabled: ${INFRAS_ONLINE_DOC_ENABLED:false}
+infras.online-doc.md-docs.staitc.path: ${INFRAS_ONLINE_DOC_MD_DOCS_STATIC_PATH:/doc/}
+infras.online-doc.api-docs.staitc.path: ${INFRAS_ONLINE_DOC_API_DOCS_STATIC_PATH:/api-docs/}
+
+
+## 平台OpenAPI
+poa.server.url: ${POA_SERVER_URL:https://poa.supwisdom.com}
+
+poa.client.id: ${POA_CLIENT_ID:id}
+poa.client.secret: ${POA_CLIENT_SECRET:secret}
+poa.scopes: ${POA_SCOPES:read,write,trust}
+
+## 开放接口地址
+user-data-service.server.url: ${USER_DATA_SERVICE_SERVER_URL:${poa.server.url}/apis/user/v1}
+user-authorization-service.server.url: ${USER_AUTHORIZATION_SERVICE_SERVER_URL:${poa.server.url}/apis/authz/v1}
+
+## 用户授权服务
+user-authorization-service.applicationId: ${USER_AUTHORIZATION_SERVICE_APPLICATION_ID:}
diff --git a/thirdparty-agent/agent/src/main/resources/application.yml b/thirdparty-agent/agent/src/main/resources/application.yml
new file mode 100644
index 0000000..001a0bd
--- /dev/null
+++ b/thirdparty-agent/agent/src/main/resources/application.yml
@@ -0,0 +1,63 @@
+server:
+ port: 8090
+ ssl:
+ enabled: false
+
+
+##
+# logging
+#
+logging:
+ level:
+ root: INFO
+ com.supwisdom: DEBUG
+# org.springframework.web: INFO
+# org.springframework.cloud.openfeign: INFO
+
+
+swagger2.apis.basePackage: com.supwisdom.institute
+
+
+spring:
+ jackson:
+ time-zone: Asia/Shanghai
+
+##
+# spring.redis
+#
+ redis:
+ database: 0
+ host: localhost
+ port: 6379
+ password:
+ timeout: 10000
+
+ jedis:
+ pool:
+ maxIdle: 8
+ minIdle: 0
+ maxActive: 8
+ maxWait: -1
+
+
+##
+# infras.online-doc
+#
+infras.online-doc.enabled: true
+infras.online-doc.md-docs.staitc.path: /Users/loie/c/work/git/institute/sw-backend/doc/
+infras.online-doc.api-docs.staitc.path: /Users/loie/c/work/git/institute/sw-backend/api-docs/
+
+
+## 平台OpenAPI
+poa.server.url: https://poa.supwisdom.com
+
+poa.client.id: nV8US9uAdFQ0ovuYpFOloXtFkME=
+poa.client.secret: dDgZAzuNnOjfsbm8iDohyVCXBU1GwImeMsmkJzjyGh8=
+poa.scopes: user:v1:readUser,user:v1:readOrganization,user:v1:readGroup,user:v1:readLabel,authz:v1:readRole
+
+## 开放接口地址
+user-data-service.server.url: ${poa.server.url}/apis/user/v1
+user-authorization-service.server.url: ${poa.server.url}/apis/authz/v1
+
+## 用户授权服务
+user-authorization-service.applicationId: 2
diff --git a/thirdparty-agent/agent/src/main/resources/bootstrap.yml b/thirdparty-agent/agent/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..92df83b
--- /dev/null
+++ b/thirdparty-agent/agent/src/main/resources/bootstrap.yml
@@ -0,0 +1,3 @@
+spring:
+ application:
+ name: sw-backend-thirdparty-agent