Merge branch 'master' of http://git.picaiba.com/why/ym
Conflicts: ym-gateway/pom.xml
This commit is contained in:
@@ -32,6 +32,27 @@
|
||||
<artifactId>ym-barcode</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cnbm</groupId>
|
||||
<artifactId>ym-basic</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -2,6 +2,7 @@ package com.cnbm;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
|
||||
/**
|
||||
* @Author weihongyang
|
||||
@@ -9,9 +10,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
* @Version 1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
|
||||
public class AdminApplication {
|
||||
@EnableOpenApi
|
||||
public class YmApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class,args);
|
||||
SpringApplication.run(YmApplication.class,args);
|
||||
}
|
||||
}
|
||||
87
ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java
Normal file
87
ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.cnbm.config;
|
||||
|
||||
import com.cnbm.common.constant.Constant;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
/**
|
||||
* @Author weihongyang
|
||||
* @Date 2022/6/21 10:56 AM
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableOpenApi
|
||||
@Profile("dev")
|
||||
public class SwaggerConfig {
|
||||
|
||||
/**
|
||||
* 创建API应用
|
||||
* apiInfo() 增加API相关信息
|
||||
* 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现,
|
||||
* 本例采用指定扫描的包路径来定义指定要建立API的目录。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Docket restApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("标准接口")
|
||||
.apiInfo(apiInfo("Spring Boot中使用Swagger2构建RESTful APIs", "1.0"))
|
||||
.useDefaultResponseMessages(true)
|
||||
.forCodeGeneration(false)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securityContexts(Arrays.asList(securityContext()))
|
||||
// ApiKey的name需与SecurityReference的reference保持一致
|
||||
.securitySchemes(Arrays.asList(new ApiKey("token", "token", "header")));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
|
||||
* 访问地址:http://ip:port/swagger-ui.html
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ApiInfo apiInfo(String title, String version) {
|
||||
return new ApiInfoBuilder()
|
||||
.title(title)
|
||||
.description("ym-pass文档")
|
||||
.termsOfServiceUrl("https://www.baidu.com/")
|
||||
.version(version)
|
||||
.build();
|
||||
}
|
||||
|
||||
private SecurityContext securityContext() {
|
||||
return SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.build();
|
||||
}
|
||||
|
||||
List<SecurityReference> defaultAuth() {
|
||||
AuthorizationScope authorizationScope
|
||||
= new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
return Lists.newArrayList(
|
||||
new SecurityReference(Constant.TOKEN_HEADER, authorizationScopes));
|
||||
}
|
||||
|
||||
}
|
||||
40
ym-gateway/src/main/resources/application-prod.yml
Normal file
40
ym-gateway/src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
spring:
|
||||
datasource:
|
||||
#MySQL
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://mysql.picaiba.com:30307/ym_pass?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 1qaz@WSX3edc$RFV
|
||||
# #Oracle
|
||||
# driver-class-name: oracle.jdbc.OracleDriver
|
||||
# url: jdbc:oracle:thin:@192.168.10.10:1521:xe
|
||||
# username: renren_security
|
||||
# password: 123456
|
||||
# #SQLServer
|
||||
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=renren_security
|
||||
# username: sa
|
||||
# password: 123456
|
||||
# #postgresql
|
||||
# driver-class-name: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://192.168.10.10:5432/postgres
|
||||
# username: postgres
|
||||
# password: 123456
|
||||
hikari:
|
||||
pool-name: GrowUpHikariCP
|
||||
minimum-idle: 1
|
||||
maximum-pool-size: 10
|
||||
|
||||
##多数据源的配置,需要引用renren-dynamic-datasource
|
||||
#dynamic:
|
||||
# datasource:
|
||||
# slave1:
|
||||
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://123456:1433;DatabaseName=renren_security
|
||||
# username: sa
|
||||
# password: 123456
|
||||
# slave2:
|
||||
# driver-class-name: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://123456:5432/renren_security
|
||||
# username: postgres
|
||||
# password: 123456
|
||||
@@ -7,14 +7,14 @@ server:
|
||||
min-spare: 30
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /ym-admin
|
||||
context-path: /ym-pass
|
||||
session:
|
||||
cookie:
|
||||
http-only: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: ym-admin
|
||||
name: ym-pass
|
||||
# 环境 dev|test|prod
|
||||
profiles:
|
||||
active: dev
|
||||
@@ -31,9 +31,9 @@ spring:
|
||||
enabled: true
|
||||
redis:
|
||||
database: 0
|
||||
host: 124.221.241.144
|
||||
port: 6379
|
||||
password: why123456 # 密码(默认为空)
|
||||
host: redis.picaiba.com
|
||||
port: 6380
|
||||
password: '@WSXcde3' # 密码(默认为空)
|
||||
timeout: 6000ms # 连接超时时长(毫秒)
|
||||
jedis:
|
||||
pool:
|
||||
|
||||
Reference in New Issue
Block a user