forked from young-datafan-ooooo1/data-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
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
song xiaolang
committed
Mar 25, 2022
1 parent
9568b97
commit 381e4c0
Showing
13 changed files
with
316 additions
and
3 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
86 changes: 86 additions & 0 deletions
86
...core/src/main/java/com/youngdatafan/dataintegration/core/config/SwaggerConfiguration.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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.youngdatafan.dataintegration.core.config; | ||
|
||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; | ||
import io.swagger.annotations.ApiOperation; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.http.HttpMethod; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.builders.ResponseBuilder; | ||
import springfox.documentation.oas.annotations.EnableOpenApi; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.service.RequestParameter; | ||
import springfox.documentation.service.Response; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
|
||
/** | ||
* swagger自动配置. | ||
* | ||
* @author gavin | ||
* @create 2020/8/21 4:39 下午 | ||
*/ | ||
@ConditionalOnClass(value = EnableOpenApi.class) | ||
@EnableOpenApi | ||
@EnableKnife4j | ||
@Configuration | ||
@Import(SwaggerHeaderTransformationFilter.class) | ||
public class SwaggerConfiguration { | ||
|
||
/** | ||
* 创建Docket. | ||
* | ||
* @return Docket | ||
*/ | ||
@Bean | ||
public Docket createRestApi() { | ||
//返回文档摘要信息 | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.apiInfo(apiInfo()) | ||
.select() | ||
//.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) | ||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) | ||
.paths(PathSelectors.any()) | ||
.build() | ||
.globalRequestParameters(getGlobalRequestParameters()) | ||
.globalResponses(HttpMethod.GET, getGlobalResponseMessage()) | ||
.globalResponses(HttpMethod.POST, getGlobalResponseMessage()); | ||
} | ||
|
||
/** | ||
* 生成接口信息,包括标题、联系人等. | ||
*/ | ||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("接口文档") | ||
.description("") | ||
.contact(new Contact("stella", "senses-ai", "[email protected]")) | ||
.version("1.0") | ||
.build(); | ||
} | ||
|
||
/** | ||
* 生成全局通用参数. | ||
*/ | ||
private List<RequestParameter> getGlobalRequestParameters() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
/** | ||
* 生成通用响应信息. | ||
*/ | ||
private List<Response> getGlobalResponseMessage() { | ||
List<Response> responseList = new ArrayList<>(); | ||
responseList.add(new ResponseBuilder().code("404").description("找不到资源").build()); | ||
return responseList; | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
.../java/com/youngdatafan/dataintegration/core/config/SwaggerHeaderTransformationFilter.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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.youngdatafan.dataintegration.core.config; | ||
|
||
import io.swagger.models.Operation; | ||
import io.swagger.models.Swagger; | ||
import io.swagger.models.parameters.Parameter; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.servlet.http.HttpServletRequest; | ||
import org.springframework.stereotype.Component; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.swagger2.web.SwaggerTransformationContext; | ||
import springfox.documentation.swagger2.web.WebMvcSwaggerTransformationFilter; | ||
|
||
/** | ||
* swagger header自定义处理过滤器. | ||
* @author gavin | ||
* @create 2022/2/9 21:06 | ||
*/ | ||
@Component | ||
public class SwaggerHeaderTransformationFilter implements WebMvcSwaggerTransformationFilter { | ||
|
||
private static final String HEADER_NAME = "X-Forwarded-Prefix"; | ||
|
||
@Override | ||
public Swagger transform(SwaggerTransformationContext<HttpServletRequest> context) { | ||
HttpServletRequest request = context.request().get(); | ||
|
||
final String basePath = request.getHeader(HEADER_NAME); | ||
if (basePath == null || !basePath.startsWith("/api")) { | ||
// 如果没有HEADER_NAME请求头,并且不是/api开头,则代表不是通过网关访问,就不需要设置header | ||
return context.getSpecification(); | ||
} | ||
|
||
Swagger swagger = context.getSpecification(); | ||
swagger.setBasePath(basePath); | ||
|
||
swagger.getPaths().forEach((s, pathItem) -> { | ||
for (Operation readOperation : pathItem.getOperations()) { | ||
final List<Parameter> parameters = readOperation.getParameters(); | ||
if (parameters == null) { | ||
continue; | ||
} | ||
|
||
List<Parameter> newParameters = new ArrayList<>(); | ||
for (Parameter parameter : parameters) { | ||
if (!parameter.getIn().equalsIgnoreCase("header")) { | ||
newParameters.add(parameter); | ||
} | ||
} | ||
readOperation.setParameters(newParameters); | ||
} | ||
}); | ||
|
||
return swagger; | ||
} | ||
|
||
@Override | ||
public boolean supports(DocumentationType documentationType) { | ||
return documentationType.equals(DocumentationType.SWAGGER_2); | ||
} | ||
|
||
} |
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
106 changes: 106 additions & 0 deletions
106
...agement/dataintegration-file-management-provider/src/main/resources/application-test.yaml
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
server: | ||
port: 10210 | ||
|
||
spring: | ||
cloud: | ||
consul: | ||
host: 192.168.10.160 | ||
port: 8500 | ||
discovery: | ||
service-name: ${spring.application.name} | ||
datasource: | ||
type: com.zaxxer.hikari.HikariDataSource | ||
driver-class-name: com.mysql.jdbc.Driver | ||
url: jdbc:mysql://192.168.10.211:13306/dataintegration?useUnicode=true&characterEncoding=utf-8&useSSL=false | ||
username: stelladp | ||
password: 123456 | ||
hikari: | ||
minimum-idle: 1 | ||
maximum-pool-size: 10 | ||
max-lifetime: 1800000 | ||
idle-timeout: 600000 | ||
connection-timeout: 30000 | ||
connection-test-query: SELECT 1 | ||
jackson: | ||
time-zone: GMT+8 | ||
date-format: yyyy-MM-dd HH:mm:ss | ||
servlet: | ||
multipart: | ||
max-file-size: 1GB | ||
max-request-size: 1GB | ||
redis: | ||
host: 192.168.10.211 | ||
port: 39121 | ||
password: | ||
lettuce: | ||
shutdown-timeout: 100 # 关闭超时时间 | ||
pool: | ||
max-active: 100 # 连接池最大连接数(使用负值表示没有限制) | ||
max-idle: 10 # 连接池中的最大空闲连接 | ||
max-wait: 1000 # 连接池最大阻塞等待时间(使用负值表示没有限制) | ||
min-idle: 1 # 连接池中的最小空闲连接 | ||
cache: | ||
type: redis | ||
|
||
#配置MyBatis | ||
mybatis: | ||
mapper-locations: classpath*:com/youngdatafan/dataintegration/file/management/mapping/*Mapper.xml | ||
configuration: | ||
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl | ||
|
||
#pagehelper | ||
pagehelper: | ||
helperDialect: mysql | ||
reasonable: true | ||
supportMethodsArguments: true | ||
params: count=countSql | ||
|
||
#ftp: | ||
# server: 127.0.0.1 | ||
# port: 20021 | ||
# userName: prime | ||
# password: prime@2020 | ||
# passiveMode: true | ||
# ftpEncoding: utf-8 | ||
#10.242.10.170:30021 | ||
|
||
|
||
#文件存储类型 | ||
file: | ||
server: | ||
useServer: s3 | ||
ftp: | ||
server: 192.168.124.166 | ||
port: 20021 | ||
userName: prime | ||
password: prime@2020 | ||
passiveMode: true | ||
ftpEncoding: utf-8 | ||
rootPath: ftp:// | ||
createDir: true | ||
s3: | ||
server: 192.168.10.211 | ||
port: 8080 | ||
userName: BMXG3WP8JA9D1GSD2AJJ | ||
password: vl32x2t0sBxy0BEgcY9Iz442HK2HobPTNw4T99yK | ||
rootPath: s3:// | ||
bucket: escat-s3 | ||
createDir: true | ||
|
||
|
||
logging: | ||
file: | ||
# 配置日志目录,logbak.xml使用 | ||
path: ./logs/${spring.application.name} | ||
# springboot admin获取日志使用 | ||
name: ${logging.file.path}/all/${spring.application.name}.log | ||
|
||
################################################## | ||
# JodConverter Configuration | ||
|
||
jodconverter: | ||
local: | ||
enabled: true | ||
office-home: /Applications/OpenOffice.app/Contents/ | ||
max-tasks-per-process: 10 | ||
port-numbers: 8123 |
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
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
Oops, something went wrong.