feat: 新增biz-sa示例,用于测试多后端微服务的项目架构
diff --git a/sa/biz/.gitignore b/sa/biz/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/sa/biz/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/sa/biz/Dockerfile b/sa/biz/Dockerfile
new file mode 100644
index 0000000..f7bf86e
--- /dev/null
+++ b/sa/biz/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/sa/biz/pom.xml b/sa/biz/pom.xml
new file mode 100644
index 0000000..aabc09e
--- /dev/null
+++ b/sa/biz/pom.xml
@@ -0,0 +1,204 @@
+<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-parent</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <relativePath>../../</relativePath>
+ </parent>
+
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-biz-sa</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Supwisdom Backend Framework Biz Super Admin</name>
+ <description>Supwisdom Backend Framework Biz Super Admin project</description>
+
+ <properties>
+ <start-class>com.supwisdom.institute.backend.biz.sa.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.cloud</groupId>
+ <artifactId>spring-cloud-starter-openfeign</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.supwisdom.infras</groupId>
+ <artifactId>infras-online-doc</artifactId>
+ </dependency>
+
+
+ <!-- <dependency>
+ <groupId>com.supwisdom.infras</groupId>
+ <artifactId>infras-mvc</artifactId>
+ </dependency> -->
+
+ <!-- <dependency>
+ <groupId>com.supwisdom.infras</groupId>
+ <artifactId>infras-object-mapper</artifactId>
+ </dependency> -->
+
+ <!-- <dependency>
+ <groupId>com.supwisdom.infras</groupId>
+ <artifactId>infras-i18n</artifactId>
+ </dependency> -->
+
+ <!-- <dependency>
+ <groupId>com.supwisdom.infras</groupId>
+ <artifactId>infras-lang</artifactId>
+ </dependency> -->
+
+
+ <dependency>
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-biz-api</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>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>runtime</scope>
+ </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.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ <executions>
+ <execution>
+ <id>copy-doc-resources</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <encoding>utf-8</encoding>
+ <outputDirectory>${basedir}/target/doc</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
+ <resource>
+ <directory>${basedir}/../doc</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-api-docs-resources</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <encoding>utf-8</encoding>
+ <outputDirectory>${basedir}/target/api-docs</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
+ <resource>
+ <directory>${basedir}/../api-docs</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </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/sa/biz/src/main/java/com/supwisdom/institute/backend/biz/sa/Application.java b/sa/biz/src/main/java/com/supwisdom/institute/backend/biz/sa/Application.java
new file mode 100644
index 0000000..b2b44be
--- /dev/null
+++ b/sa/biz/src/main/java/com/supwisdom/institute/backend/biz/sa/Application.java
@@ -0,0 +1,47 @@
+package com.supwisdom.institute.backend.biz.sa;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+import com.supwisdom.infras.online.doc.configuration.EnableInfrasOnlineDoc;
+import com.supwisdom.institute.backend.common.core.transmit.annotation.EnableSimpleUserTransmit;
+import com.supwisdom.institute.backend.common.framework.exception.EnableCustomExceptionHandler;
+
+@SpringBootApplication
+
+@EnableSimpleUserTransmit
+@EnableCustomExceptionHandler
+
+@EnableInfrasOnlineDoc
+
+@EntityScan(basePackages = {"com.supwisdom.**.domain.entity"}) // 扫描子项目下的实体
+@EnableJpaRepositories(basePackages = {"com.supwisdom.**.domain.repo"}) // 扫描子项目下的持久类
+@ComponentScan(basePackages = {"com.supwisdom"})
+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/sa/biz/src/main/java/com/supwisdom/institute/backend/biz/sa/configuration/Swagger2Config.java b/sa/biz/src/main/java/com/supwisdom/institute/backend/biz/sa/configuration/Swagger2Config.java
new file mode 100644
index 0000000..f2ffe33
--- /dev/null
+++ b/sa/biz/src/main/java/com/supwisdom/institute/backend/biz/sa/configuration/Swagger2Config.java
@@ -0,0 +1,110 @@
+package com.supwisdom.institute.backend.biz.sa.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 Biz Super Admin", "https://sw-backend-biz-sa.supwisdom.com/swagger-ui.html", ""); // name, url, email
+ return new ApiInfoBuilder()
+ .title("Backend Biz Super Admin 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/sa/biz/src/main/resources/application-docker.yml b/sa/biz/src/main/resources/application-docker.yml
new file mode 100644
index 0000000..cbf3924
--- /dev/null
+++ b/sa/biz/src/main/resources/application-docker.yml
@@ -0,0 +1,46 @@
+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}
+
+ datasource:
+ driver-class-name: ${JDBC_DRIVER_CLASS_NAME:com.mysql.cj.jdbc.Driver}
+ url: ${JDBC_URL:jdbc:mysql://mysql-server:3306/sw-biz}
+ username: ${JDBC_USERNAME:sw-biz}
+ password: ${JDBC_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/}
diff --git a/sa/biz/src/main/resources/application.yml b/sa/biz/src/main/resources/application.yml
new file mode 100644
index 0000000..531f8bd
--- /dev/null
+++ b/sa/biz/src/main/resources/application.yml
@@ -0,0 +1,48 @@
+server:
+ port: 8083
+ 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
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/sw-biz
+ username: root
+ password: root
+ hikari:
+ data-source-properties:
+ useSSL: false
+ characterEncoding: utf8
+ characterSetResults: utf8
+ jpa:
+ hibernate:
+ ddl-auto: none
+ naming:
+ physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ show-sql: false
+
+
+##
+# 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/
diff --git a/sa/biz/src/main/resources/bootstrap.yml b/sa/biz/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..8c1026a
--- /dev/null
+++ b/sa/biz/src/main/resources/bootstrap.yml
@@ -0,0 +1,3 @@
+spring:
+ application:
+ name: sw-backend-biz-sa
diff --git a/sa/pom.xml b/sa/pom.xml
index 6aafbda..40724ff 100644
--- a/sa/pom.xml
+++ b/sa/pom.xml
@@ -19,6 +19,7 @@
<modules>
<module>admin</module>
+ <module>biz</module>
</modules>
<build>
diff --git a/sql/biz.sql b/sql/biz.sql
new file mode 100644
index 0000000..7e8b585
--- /dev/null
+++ b/sql/biz.sql
@@ -0,0 +1,20 @@
+
+CREATE TABLE `TB_BIZ` (
+ `ID` VARCHAR(100) NOT NULL COMMENT '',
+ `COMPANY_ID` VARCHAR(100) COMMENT 'CompanyID',
+ `DELETED` INT(1) COMMENT '是否删除',
+ `ADD_ACCOUNT` VARCHAR(100) COMMENT '创建人',
+ `ADD_TIME` DATETIME COMMENT '创建时间',
+ `EDIT_ACCOUNT` VARCHAR(100) COMMENT '修改人',
+ `EDIT_TIME` DATETIME COMMENT '修改时间',
+ `DELETE_ACCOUNT` VARCHAR(100) COMMENT '删除人',
+ `DELETE_TIME` DATETIME COMMENT '删除时间',
+
+ `NAME` VARCHAR(200) NOT NULL COMMENT '名称',
+ `BOOL` INT(1) NOT NULL COMMENT '布尔',
+ `DATE` DATETIME COMMENT '时间',
+ `NUM` INT(11) NOT NULL COMMENT '数字',
+
+ PRIMARY KEY (`ID`)
+)
+COMMENT = '测试表';