Skip to content

Commit

Permalink
beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Jan 9, 2022
1 parent e4640e6 commit ca0494c
Show file tree
Hide file tree
Showing 215 changed files with 3,773 additions and 2,940 deletions.
2 changes: 1 addition & 1 deletion config/sonic-server-gateway-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ server:
port: 8094

filter:
white-list: /users/login,/users/register,/swagger-resources,/v2/api-docs,/folder/upload,/folder/recordFiles,/keepFiles/,/imageFiles/,/recordFiles/,/logFiles/,/packageFiles/
white-list: /users/login,/users/register,/swagger-resources,/v2/api-docs,/folder/upload,/folder/upload/recordFiles,/folder/upload/cv,/keepFiles/,/imageFiles/,/recordFiles/,/logFiles/,/packageFiles/

spring:
cloud:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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>

<groupId>com.sonic</groupId>
<groupId>org.cloud.sonic</groupId>
<artifactId>sonic-server</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
Expand Down
42 changes: 21 additions & 21 deletions sonic-server-bus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>sonic-server</artifactId>
<groupId>com.sonic</groupId>
<groupId>org.cloud.sonic</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>sonic-server-bus</artifactId>
<version>v1.2.0-release</version>
<version>v1.3.0-beta2</version>
<packaging>jar</packaging>

<dependencies>
Expand Down Expand Up @@ -42,23 +42,23 @@
</dependency>
</dependencies>

<build>
<plugins>
<!-- 只作为公共依赖,不需要打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<skipDocker>true</skipDocker>
</configuration>
</plugin>
</plugins>
</build>
<!-- <build>-->
<!-- <plugins>-->
<!-- &lt;!&ndash; 只作为公共依赖,不需要打包 &ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <skip>true</skip>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>com.spotify</groupId>-->
<!-- <artifactId>docker-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <skipDocker>true</skipDocker>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
</project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.sonic.bus;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

@SpringBootApplication
@EnableEurekaClient
@EnableConfigServer
public class BusApplication {
public static void main(String[] args) {
SpringApplication.run(BusApplication.class, args);
}
package org.cloud.sonic.bus;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

@SpringBootApplication
@EnableEurekaClient
@EnableConfigServer
public class BusApplication {
public static void main(String[] args) {
SpringApplication.run(BusApplication.class, args);
}
}
2 changes: 1 addition & 1 deletion sonic-server-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>sonic-server</artifactId>
<groupId>com.sonic</groupId>
<groupId>org.cloud.sonic</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
package com.sonic.common.config;

import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
* @author ZhouYiXun
* @des swagger配置
* @date 2021/8/15 18:26
*/
@Configuration
@EnableSwagger2WebMvc
public class APIDocumentConfig {
//从配置文档获取接口文档信息
@Value("${spring.application.name}")
private String name;
@Value("${spring.application.des}")
private String title;
@Value("${spring.version}")
private String version;
@Value("${knife4j.setting.enableHostText}")
private String host;

private final OpenApiExtensionResolver openApiExtensionResolver;

/**
* @param openApiExtensionResolver
* @return 开启knife4j接口插件
* @author ZhouYiXun
* @des
* @date 2021/8/15 23:22
*/
@Autowired
public APIDocumentConfig(OpenApiExtensionResolver openApiExtensionResolver) {
this.openApiExtensionResolver = openApiExtensionResolver;
}

/**
* @return springfox.documentation.spring.web.plugins.Docket
* @author ZhouYiXun
* @des 生成最终文档的配置,默认所有路径
* @date 2021/8/15 22:55
*/
@Bean
public Docket createRestAPIDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.host(host)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build()
.extensions(openApiExtensionResolver.buildSettingExtensions())
.useDefaultResponseMessages(false)
.securitySchemes(Arrays.asList(
new ApiKey("SonicToken", "SonicToken", "header")))
.securityContexts(securityContexts());
}

/**
* @return java.util.List<springfox.documentation.spi.service.contexts.SecurityContext>
* @author ZhouYiXun
* @des 放开Login的token校验
* @date 2021/8/15 22:53
*/
private List<SecurityContext> securityContexts() {
return Arrays.asList(
SecurityContext.builder()
.securityReferences(auth())
.forPaths(PathSelectors.regex("^((?!(register|login)).)*$"))
.build()
);
}

/**
* @return java.util.List<springfox.documentation.service.SecurityReference>
* @author ZhouYiXun
* @des 设置SonicToken在接口文档页面
* @date 2021/8/15 22:54
*/
private List<SecurityReference> auth() {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
return Arrays.asList(
new SecurityReference("SonicToken", authorizationScopes));
}

/**
* @return springfox.documentation.service.ApiInfo
* @author ZhouYiXun
* @des 接口文档信息,从配置文件获取
* @date 2021/8/15 22:54
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(title + " Open API")
.termsOfServiceUrl("Please visit: https://github.com/SonicCloudOrg/sonic-server")
.contact(new Contact("ZhouYiXun email: [email protected]", "", ""))
.version(version)
.description(name + " 服务开放API,注意不要频繁请求。")
.build();
}
package org.cloud.sonic.common.config;

import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
* @author ZhouYiXun
* @des swagger配置
* @date 2021/8/15 18:26
*/
@Configuration
@EnableSwagger2WebMvc
public class APIDocumentConfig {
//从配置文档获取接口文档信息
@Value("${spring.application.name}")
private String name;
@Value("${spring.application.des}")
private String title;
@Value("${spring.version}")
private String version;
@Value("${knife4j.setting.enableHostText}")
private String host;

private final OpenApiExtensionResolver openApiExtensionResolver;

/**
* @param openApiExtensionResolver
* @return 开启knife4j接口插件
* @author ZhouYiXun
* @des
* @date 2021/8/15 23:22
*/
@Autowired
public APIDocumentConfig(OpenApiExtensionResolver openApiExtensionResolver) {
this.openApiExtensionResolver = openApiExtensionResolver;
}

/**
* @return springfox.documentation.spring.web.plugins.Docket
* @author ZhouYiXun
* @des 生成最终文档的配置,默认所有路径
* @date 2021/8/15 22:55
*/
@Bean
public Docket createRestAPIDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.host(host)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build()
.extensions(openApiExtensionResolver.buildSettingExtensions())
.useDefaultResponseMessages(false)
.securitySchemes(Arrays.asList(
new ApiKey("SonicToken", "SonicToken", "header")))
.securityContexts(securityContexts());
}

/**
* @return java.util.List<springfox.documentation.spi.service.contexts.SecurityContext>
* @author ZhouYiXun
* @des 放开Login的token校验
* @date 2021/8/15 22:53
*/
private List<SecurityContext> securityContexts() {
return Arrays.asList(
SecurityContext.builder()
.securityReferences(auth())
.forPaths(PathSelectors.regex("^((?!(register|login)).)*$"))
.build()
);
}

/**
* @return java.util.List<springfox.documentation.service.SecurityReference>
* @author ZhouYiXun
* @des 设置SonicToken在接口文档页面
* @date 2021/8/15 22:54
*/
private List<SecurityReference> auth() {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
return Arrays.asList(
new SecurityReference("SonicToken", authorizationScopes));
}

/**
* @return springfox.documentation.service.ApiInfo
* @author ZhouYiXun
* @des 接口文档信息,从配置文件获取
* @date 2021/8/15 22:54
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(title + " Open API")
.termsOfServiceUrl("Please visit: https://github.com/SonicCloudOrg/sonic-server")
.contact(new Contact("ZhouYiXun email: [email protected]", "", ""))
.version(version)
.description(name + " 服务开放API,注意不要频繁请求。")
.build();
}
}
Loading

0 comments on commit ca0494c

Please sign in to comment.