-
-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
215 changed files
with
3,773 additions
and
2,940 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
...in/java/com/sonic/bus/BusApplication.java → ...a/org/cloud/sonic/bus/BusApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
238 changes: 119 additions & 119 deletions
238
...onic/common/config/APIDocumentConfig.java → ...onic/common/config/APIDocumentConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.