Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄营
datax-cloud
Commits
ccb828df
Commit
ccb828df
authored
Aug 10, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
6a175309
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
928 additions
and
0 deletions
+928
-0
DataxMasterdataApplication.java
...x/service/data/masterdata/DataxMasterdataApplication.java
+14
-0
DataResourceServerConfig.java
...vice/data/masterdata/config/DataResourceServerConfig.java
+67
-0
StartedUpRunner.java
...datax/service/data/masterdata/config/StartedUpRunner.java
+31
-0
SwaggerConfig.java
...n/datax/service/data/masterdata/config/SwaggerConfig.java
+117
-0
SwaggerProperties.java
...tax/service/data/masterdata/config/SwaggerProperties.java
+101
-0
bootstrap.yml
.../data-masterdata-service/src/main/resources/bootstrap.yml
+29
-0
logback-spring.xml
...-masterdata-service/src/main/resources/logback-spring.xml
+79
-0
spy.properties
...data-masterdata-service/src/main/resources/spy.properties
+26
-0
DataxStandardApplication.java
...datax/service/data/standard/DataxStandardApplication.java
+14
-0
DataResourceServerConfig.java
...ervice/data/standard/config/DataResourceServerConfig.java
+67
-0
StartedUpRunner.java
...n/datax/service/data/standard/config/StartedUpRunner.java
+31
-0
SwaggerConfig.java
.../cn/datax/service/data/standard/config/SwaggerConfig.java
+117
-0
SwaggerProperties.java
...datax/service/data/standard/config/SwaggerProperties.java
+101
-0
bootstrap.yml
...nt/data-standard-service/src/main/resources/bootstrap.yml
+29
-0
logback-spring.xml
...ta-standard-service/src/main/resources/logback-spring.xml
+79
-0
spy.properties
...t/data-standard-service/src/main/resources/spy.properties
+26
-0
No files found.
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/java/cn/datax/service/data/masterdata/DataxMasterdataApplication.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
masterdata
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableFeignClients
(
basePackages
=
{
"cn.datax.service.system.api.feign"
})
@SpringCloudApplication
public
class
DataxMasterdataApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DataxMasterdataApplication
.
class
);
}
}
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/java/cn/datax/service/data/masterdata/config/DataResourceServerConfig.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
masterdata
.
config
;
import
cn.datax.common.security.handler.DataAccessDeniedHandler
;
import
cn.datax.common.security.handler.DataAuthExceptionEntryPoint
;
import
cn.datax.common.security.utils.DataRedisTokenServices
;
import
cn.datax.common.security.utils.RedisTokenStore
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter
;
import
org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer
;
import
org.springframework.security.oauth2.provider.token.TokenStore
;
@Configuration
@EnableResourceServer
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
public
class
DataResourceServerConfig
extends
ResourceServerConfigurerAdapter
{
@Autowired
private
DataAccessDeniedHandler
accessDeniedHandler
;
@Autowired
private
DataAuthExceptionEntryPoint
exceptionEntryPoint
;
@Autowired
private
RedisConnectionFactory
redisConnectionFactory
;
@Bean
public
TokenStore
redisTokenStore
()
{
return
new
RedisTokenStore
(
redisConnectionFactory
);
}
@Override
public
void
configure
(
ResourceServerSecurityConfigurer
resources
)
{
DataRedisTokenServices
dataTokenServices
=
new
DataRedisTokenServices
();
dataTokenServices
.
setTokenStore
(
redisTokenStore
());
resources
.
tokenStore
(
redisTokenStore
())
.
tokenServices
(
dataTokenServices
)
.
authenticationEntryPoint
(
exceptionEntryPoint
)
.
accessDeniedHandler
(
accessDeniedHandler
);
}
@Override
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
//允许使用iframe 嵌套,避免swagger-ui 不被加载的问题
http
.
headers
().
frameOptions
().
disable
();
http
.
authorizeRequests
()
.
antMatchers
(
"/actuator/**"
,
"/v2/api-docs/**"
,
"/swagger-ui.html"
,
"/doc.html"
,
"/swagger-resources/**"
,
"/webjars/**"
,
// feign 内部调用不用授权
"/inner/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
().
csrf
().
disable
();
}
}
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/java/cn/datax/service/data/masterdata/config/StartedUpRunner.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
masterdata
.
config
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
@Component
@RequiredArgsConstructor
public
class
StartedUpRunner
implements
ApplicationRunner
{
private
final
ConfigurableApplicationContext
context
;
private
final
Environment
environment
;
@Override
public
void
run
(
ApplicationArguments
args
)
{
if
(
context
.
isActive
())
{
String
banner
=
"-----------------------------------------\n"
+
"服务启动成功,时间:"
+
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
LocalDateTime
.
now
())
+
"\n"
+
"服务名称:"
+
environment
.
getProperty
(
"spring.application.name"
)
+
"\n"
+
"端口号:"
+
environment
.
getProperty
(
"server.port"
)
+
"\n"
+
"-----------------------------------------"
;
System
.
out
.
println
(
banner
);
}
}
}
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/java/cn/datax/service/data/masterdata/config/SwaggerConfig.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
masterdata
.
config
;
import
com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration
;
import
springfox.documentation.builders.*
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.service.*
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
java.util.ArrayList
;
import
java.util.List
;
@Configuration
@ConditionalOnProperty
(
prefix
=
"swagger"
,
name
=
"enable"
,
havingValue
=
"true"
)
@EnableConfigurationProperties
(
SwaggerProperties
.
class
)
@EnableSwagger2
@EnableKnife4j
@Import
(
BeanValidatorPluginsConfiguration
.
class
)
public
class
SwaggerConfig
{
@Autowired
private
SwaggerProperties
swaggerProperties
;
/**
* 创建API应用
* apiInfo() 增加API相关信息
* 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现,
* 本例采用指定扫描的包路径来定义指定要建立API的目录。
*
* @return
*/
@Bean
public
Docket
createRestApi
(){
//版本类型是swagger2
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
//通过调用自定义方法apiInfo,获得文档的主要信息
.
apiInfo
(
apiInfo
())
//设置全局参数
.
globalOperationParameters
(
globalParamBuilder
())
//设置全局响应参数
.
globalResponseMessage
(
RequestMethod
.
GET
,
responseBuilder
())
.
globalResponseMessage
(
RequestMethod
.
POST
,
responseBuilder
())
.
globalResponseMessage
(
RequestMethod
.
PUT
,
responseBuilder
())
.
globalResponseMessage
(
RequestMethod
.
DELETE
,
responseBuilder
())
.
select
()
//扫描该包下面的API注解
.
apis
(
RequestHandlerSelectors
.
basePackage
(
swaggerProperties
.
getBasePackage
()))
.
paths
(
PathSelectors
.
any
())
.
build
()
//设置安全认证
.
securitySchemes
(
security
());
}
/**
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
* 访问地址:http://项目实际地址/swagger-ui.html
* @return
*/
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
swaggerProperties
.
getTitle
())
.
description
(
swaggerProperties
.
getDescription
())
.
termsOfServiceUrl
(
swaggerProperties
.
getTermsOfServiceUrl
())
.
version
(
swaggerProperties
.
getVersion
())
.
contact
(
new
Contact
(
swaggerProperties
.
getContact
().
getName
(),
swaggerProperties
.
getContact
().
getUrl
(),
swaggerProperties
.
getContact
().
getEmail
()))
.
build
();
}
/**
* 安全认证参数
* @return
*/
private
List
<
ApiKey
>
security
()
{
List
<
ApiKey
>
apiKeys
=
new
ArrayList
<>();
apiKeys
.
add
(
new
ApiKey
(
"Authorization"
,
"Authorization"
,
"header"
));
return
apiKeys
;
}
/**
* 构建全局参数列表
* @return
*/
private
List
<
Parameter
>
globalParamBuilder
(){
List
<
Parameter
>
pars
=
new
ArrayList
<>();
pars
.
add
(
parameterBuilder
(
"Authorization"
,
"令牌"
,
"string"
,
"header"
,
false
).
build
());
return
pars
;
}
/**
* 创建参数
* @return
*/
private
ParameterBuilder
parameterBuilder
(
String
name
,
String
desc
,
String
type
,
String
parameterType
,
boolean
required
)
{
ParameterBuilder
tokenPar
=
new
ParameterBuilder
();
tokenPar
.
name
(
name
).
description
(
desc
).
modelRef
(
new
ModelRef
(
type
)).
parameterType
(
parameterType
).
required
(
required
).
build
();
return
tokenPar
;
}
/**
* 创建全局响应值
* @return
*/
private
List
<
ResponseMessage
>
responseBuilder
()
{
List
<
ResponseMessage
>
responseMessageList
=
new
ArrayList
<>();
responseMessageList
.
add
(
new
ResponseMessageBuilder
().
code
(
200
).
message
(
"响应成功"
).
build
());
responseMessageList
.
add
(
new
ResponseMessageBuilder
().
code
(
500
).
message
(
"服务器内部错误"
).
build
());
return
responseMessageList
;
}
}
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/java/cn/datax/service/data/masterdata/config/SwaggerProperties.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
masterdata
.
config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@ConfigurationProperties
(
ignoreUnknownFields
=
false
,
prefix
=
"swagger"
)
public
class
SwaggerProperties
{
private
Boolean
enable
;
private
String
title
;
private
String
description
;
private
String
version
;
private
String
termsOfServiceUrl
;
private
String
basePackage
;
private
Contact
contact
;
public
Boolean
getEnable
()
{
return
enable
;
}
public
void
setEnable
(
Boolean
enable
)
{
this
.
enable
=
enable
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getTermsOfServiceUrl
()
{
return
termsOfServiceUrl
;
}
public
void
setTermsOfServiceUrl
(
String
termsOfServiceUrl
)
{
this
.
termsOfServiceUrl
=
termsOfServiceUrl
;
}
public
String
getBasePackage
()
{
return
basePackage
;
}
public
void
setBasePackage
(
String
basePackage
)
{
this
.
basePackage
=
basePackage
;
}
public
Contact
getContact
()
{
return
contact
;
}
public
void
setContact
(
Contact
contact
)
{
this
.
contact
=
contact
;
}
public
static
class
Contact
{
private
String
name
;
private
String
url
;
private
String
email
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
}
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/resources/bootstrap.yml
0 → 100644
View file @
ccb828df
server
:
port
:
8827
spring
:
application
:
name
:
datax-service-data-masterdata
profiles
:
active
:
dev
cloud
:
config
:
fail-fast
:
true
name
:
${spring.application.name}
profile
:
${spring.profiles.active}
discovery
:
enabled
:
true
service-id
:
datax-config
# 注册中心配置
eureka
:
instance
:
lease-renewal-interval-in-seconds
:
20
client
:
register-with-eureka
:
true
fetch-registry
:
true
instance-info-replication-interval-seconds
:
30
registry-fetch-interval-seconds
:
3
service-url
:
defaultZone
:
http://localhost:8610/eureka
\ No newline at end of file
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/resources/logback-spring.xml
0 → 100644
View file @
ccb828df
<?xml version="1.0" encoding="UTF-8"?>
<configuration
scan=
"true"
scanPeriod=
"60 seconds"
debug=
"false"
>
<springProperty
scope=
"context"
name=
"springAppName"
source=
"spring.application.name"
/>
<property
name=
"log.path"
value=
"logs/datax-service-data-visual"
/>
<property
name=
"log.maxHistory"
value=
"15"
/>
<property
name=
"log.totalSizeCap"
value=
"500MB"
/>
<property
name=
"log.maxFileSize"
value=
"10MB"
/>
<property
name=
"log.colorPattern"
value=
"%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %boldCyan(${springAppName:-}) %yellow(%thread) %green(%logger) %msg%n"
/>
<property
name=
"log.pattern"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${springAppName:-} %thread %logger %msg%n"
/>
<!--输出到控制台-->
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<pattern>
${log.colorPattern}
</pattern>
</encoder>
</appender>
<!--输出到文件-->
<!-- RollingFileAppender:滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 -->
<!-- 以下的大概意思是:1.先按日期存日志,日期变了,将前一天的日志文件名重命名为XXX%日期%索引,新的日志仍然是project_info.log -->
<!-- 2.如果日期没有发生变化,但是当前日志的文件大小超过10MB时,对当前日志进行分割 重命名-->
<appender
name=
"file_info"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!--日志文件路径和名称-->
<File>
${log.path}/info/info.log
</File>
<!--是否追加到文件末尾,默认为true-->
<append>
true
</append>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- 日志文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 -->
<!-- 文件名:logs/project_info.2017-12-05.0.log -->
<!-- 注意:SizeAndTimeBasedRollingPolicy中 %i和%d令牌都是强制性的,必须存在,要不会报错 -->
<fileNamePattern>
${log.path}/info/info.%d.%i.log
</fileNamePattern>
<!-- 每产生一个日志文件,该日志文件的保存期限为30天, ps:maxHistory的单位是根据fileNamePattern中的翻转策略自动推算出来的,例如上面选用了yyyy-MM-dd,则单位为天
如果上面选用了yyyy-MM,则单位为月,另外上面的单位默认为yyyy-MM-dd-->
<MaxHistory>
${log.maxHistory}
</MaxHistory>
<!-- 每个日志文件到2mb的时候开始切分,最多保留30天,但最大到500MB,哪怕没到30天也要删除多余的日志 -->
<totalSizeCap>
${log.totalSizeCap}
</totalSizeCap>
<!-- maxFileSize:这是活动文件的大小,默认值是10MB,测试时可改成5KB看效果 -->
<maxFileSize>
${log.maxFileSize}
</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>
${log.pattern}
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<appender
name=
"file_error"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${log.path}/error/error.log
</File>
<append>
true
</append>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<fileNamePattern>
${log.path}/error/error.%d.%i.log
</fileNamePattern>
<MaxHistory>
${log.maxHistory}
</MaxHistory>
<totalSizeCap>
${log.totalSizeCap}
</totalSizeCap>
<maxFileSize>
${log.maxFileSize}
</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>
${log.pattern}
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<root
level=
"debug"
>
<appender-ref
ref=
"console"
/>
</root>
<root
level=
"info"
>
<appender-ref
ref=
"file_info"
/>
<appender-ref
ref=
"file_error"
/>
</root>
</configuration>
\ No newline at end of file
datax-modules/data-masterdata-service-parent/data-masterdata-service/src/main/resources/spy.properties
0 → 100644
View file @
ccb828df
module.log
=
com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat
=
com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
appender
=
com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
# 使用日志系统记录 sql
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
deregisterdrivers
=
true
# 取消JDBC URL前缀
useprefix
=
true
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
excludecategories
=
info,debug,result,batch,resultset
# 日期格式
dateformat
=
yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection
=
true
# 慢SQL记录标准 2 秒
outagedetectioninterval
=
2
# 开启过滤
filter
=
true
# 配置不打印的内容
exclude
=
select 1
\ No newline at end of file
datax-modules/data-standard-service-parent/data-standard-service/src/main/java/cn/datax/service/data/standard/DataxStandardApplication.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
standard
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableFeignClients
(
basePackages
=
{
"cn.datax.service.system.api.feign"
})
@SpringCloudApplication
public
class
DataxStandardApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DataxStandardApplication
.
class
);
}
}
datax-modules/data-standard-service-parent/data-standard-service/src/main/java/cn/datax/service/data/standard/config/DataResourceServerConfig.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
standard
.
config
;
import
cn.datax.common.security.handler.DataAccessDeniedHandler
;
import
cn.datax.common.security.handler.DataAuthExceptionEntryPoint
;
import
cn.datax.common.security.utils.DataRedisTokenServices
;
import
cn.datax.common.security.utils.RedisTokenStore
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter
;
import
org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer
;
import
org.springframework.security.oauth2.provider.token.TokenStore
;
@Configuration
@EnableResourceServer
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
public
class
DataResourceServerConfig
extends
ResourceServerConfigurerAdapter
{
@Autowired
private
DataAccessDeniedHandler
accessDeniedHandler
;
@Autowired
private
DataAuthExceptionEntryPoint
exceptionEntryPoint
;
@Autowired
private
RedisConnectionFactory
redisConnectionFactory
;
@Bean
public
TokenStore
redisTokenStore
()
{
return
new
RedisTokenStore
(
redisConnectionFactory
);
}
@Override
public
void
configure
(
ResourceServerSecurityConfigurer
resources
)
{
DataRedisTokenServices
dataTokenServices
=
new
DataRedisTokenServices
();
dataTokenServices
.
setTokenStore
(
redisTokenStore
());
resources
.
tokenStore
(
redisTokenStore
())
.
tokenServices
(
dataTokenServices
)
.
authenticationEntryPoint
(
exceptionEntryPoint
)
.
accessDeniedHandler
(
accessDeniedHandler
);
}
@Override
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
//允许使用iframe 嵌套,避免swagger-ui 不被加载的问题
http
.
headers
().
frameOptions
().
disable
();
http
.
authorizeRequests
()
.
antMatchers
(
"/actuator/**"
,
"/v2/api-docs/**"
,
"/swagger-ui.html"
,
"/doc.html"
,
"/swagger-resources/**"
,
"/webjars/**"
,
// feign 内部调用不用授权
"/inner/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
().
csrf
().
disable
();
}
}
datax-modules/data-standard-service-parent/data-standard-service/src/main/java/cn/datax/service/data/standard/config/StartedUpRunner.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
standard
.
config
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
@Component
@RequiredArgsConstructor
public
class
StartedUpRunner
implements
ApplicationRunner
{
private
final
ConfigurableApplicationContext
context
;
private
final
Environment
environment
;
@Override
public
void
run
(
ApplicationArguments
args
)
{
if
(
context
.
isActive
())
{
String
banner
=
"-----------------------------------------\n"
+
"服务启动成功,时间:"
+
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
LocalDateTime
.
now
())
+
"\n"
+
"服务名称:"
+
environment
.
getProperty
(
"spring.application.name"
)
+
"\n"
+
"端口号:"
+
environment
.
getProperty
(
"server.port"
)
+
"\n"
+
"-----------------------------------------"
;
System
.
out
.
println
(
banner
);
}
}
}
datax-modules/data-standard-service-parent/data-standard-service/src/main/java/cn/datax/service/data/standard/config/SwaggerConfig.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
standard
.
config
;
import
com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration
;
import
springfox.documentation.builders.*
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.service.*
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
java.util.ArrayList
;
import
java.util.List
;
@Configuration
@ConditionalOnProperty
(
prefix
=
"swagger"
,
name
=
"enable"
,
havingValue
=
"true"
)
@EnableConfigurationProperties
(
SwaggerProperties
.
class
)
@EnableSwagger2
@EnableKnife4j
@Import
(
BeanValidatorPluginsConfiguration
.
class
)
public
class
SwaggerConfig
{
@Autowired
private
SwaggerProperties
swaggerProperties
;
/**
* 创建API应用
* apiInfo() 增加API相关信息
* 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现,
* 本例采用指定扫描的包路径来定义指定要建立API的目录。
*
* @return
*/
@Bean
public
Docket
createRestApi
(){
//版本类型是swagger2
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
//通过调用自定义方法apiInfo,获得文档的主要信息
.
apiInfo
(
apiInfo
())
//设置全局参数
.
globalOperationParameters
(
globalParamBuilder
())
//设置全局响应参数
.
globalResponseMessage
(
RequestMethod
.
GET
,
responseBuilder
())
.
globalResponseMessage
(
RequestMethod
.
POST
,
responseBuilder
())
.
globalResponseMessage
(
RequestMethod
.
PUT
,
responseBuilder
())
.
globalResponseMessage
(
RequestMethod
.
DELETE
,
responseBuilder
())
.
select
()
//扫描该包下面的API注解
.
apis
(
RequestHandlerSelectors
.
basePackage
(
swaggerProperties
.
getBasePackage
()))
.
paths
(
PathSelectors
.
any
())
.
build
()
//设置安全认证
.
securitySchemes
(
security
());
}
/**
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
* 访问地址:http://项目实际地址/swagger-ui.html
* @return
*/
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
swaggerProperties
.
getTitle
())
.
description
(
swaggerProperties
.
getDescription
())
.
termsOfServiceUrl
(
swaggerProperties
.
getTermsOfServiceUrl
())
.
version
(
swaggerProperties
.
getVersion
())
.
contact
(
new
Contact
(
swaggerProperties
.
getContact
().
getName
(),
swaggerProperties
.
getContact
().
getUrl
(),
swaggerProperties
.
getContact
().
getEmail
()))
.
build
();
}
/**
* 安全认证参数
* @return
*/
private
List
<
ApiKey
>
security
()
{
List
<
ApiKey
>
apiKeys
=
new
ArrayList
<>();
apiKeys
.
add
(
new
ApiKey
(
"Authorization"
,
"Authorization"
,
"header"
));
return
apiKeys
;
}
/**
* 构建全局参数列表
* @return
*/
private
List
<
Parameter
>
globalParamBuilder
(){
List
<
Parameter
>
pars
=
new
ArrayList
<>();
pars
.
add
(
parameterBuilder
(
"Authorization"
,
"令牌"
,
"string"
,
"header"
,
false
).
build
());
return
pars
;
}
/**
* 创建参数
* @return
*/
private
ParameterBuilder
parameterBuilder
(
String
name
,
String
desc
,
String
type
,
String
parameterType
,
boolean
required
)
{
ParameterBuilder
tokenPar
=
new
ParameterBuilder
();
tokenPar
.
name
(
name
).
description
(
desc
).
modelRef
(
new
ModelRef
(
type
)).
parameterType
(
parameterType
).
required
(
required
).
build
();
return
tokenPar
;
}
/**
* 创建全局响应值
* @return
*/
private
List
<
ResponseMessage
>
responseBuilder
()
{
List
<
ResponseMessage
>
responseMessageList
=
new
ArrayList
<>();
responseMessageList
.
add
(
new
ResponseMessageBuilder
().
code
(
200
).
message
(
"响应成功"
).
build
());
responseMessageList
.
add
(
new
ResponseMessageBuilder
().
code
(
500
).
message
(
"服务器内部错误"
).
build
());
return
responseMessageList
;
}
}
datax-modules/data-standard-service-parent/data-standard-service/src/main/java/cn/datax/service/data/standard/config/SwaggerProperties.java
0 → 100644
View file @
ccb828df
package
cn
.
datax
.
service
.
data
.
standard
.
config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@ConfigurationProperties
(
ignoreUnknownFields
=
false
,
prefix
=
"swagger"
)
public
class
SwaggerProperties
{
private
Boolean
enable
;
private
String
title
;
private
String
description
;
private
String
version
;
private
String
termsOfServiceUrl
;
private
String
basePackage
;
private
Contact
contact
;
public
Boolean
getEnable
()
{
return
enable
;
}
public
void
setEnable
(
Boolean
enable
)
{
this
.
enable
=
enable
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getTermsOfServiceUrl
()
{
return
termsOfServiceUrl
;
}
public
void
setTermsOfServiceUrl
(
String
termsOfServiceUrl
)
{
this
.
termsOfServiceUrl
=
termsOfServiceUrl
;
}
public
String
getBasePackage
()
{
return
basePackage
;
}
public
void
setBasePackage
(
String
basePackage
)
{
this
.
basePackage
=
basePackage
;
}
public
Contact
getContact
()
{
return
contact
;
}
public
void
setContact
(
Contact
contact
)
{
this
.
contact
=
contact
;
}
public
static
class
Contact
{
private
String
name
;
private
String
url
;
private
String
email
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
}
datax-modules/data-standard-service-parent/data-standard-service/src/main/resources/bootstrap.yml
0 → 100644
View file @
ccb828df
server
:
port
:
8824
spring
:
application
:
name
:
datax-service-data-standard
profiles
:
active
:
dev
cloud
:
config
:
fail-fast
:
true
name
:
${spring.application.name}
profile
:
${spring.profiles.active}
discovery
:
enabled
:
true
service-id
:
datax-config
# 注册中心配置
eureka
:
instance
:
lease-renewal-interval-in-seconds
:
20
client
:
register-with-eureka
:
true
fetch-registry
:
true
instance-info-replication-interval-seconds
:
30
registry-fetch-interval-seconds
:
3
service-url
:
defaultZone
:
http://localhost:8610/eureka
\ No newline at end of file
datax-modules/data-standard-service-parent/data-standard-service/src/main/resources/logback-spring.xml
0 → 100644
View file @
ccb828df
<?xml version="1.0" encoding="UTF-8"?>
<configuration
scan=
"true"
scanPeriod=
"60 seconds"
debug=
"false"
>
<springProperty
scope=
"context"
name=
"springAppName"
source=
"spring.application.name"
/>
<property
name=
"log.path"
value=
"logs/datax-service-data-visual"
/>
<property
name=
"log.maxHistory"
value=
"15"
/>
<property
name=
"log.totalSizeCap"
value=
"500MB"
/>
<property
name=
"log.maxFileSize"
value=
"10MB"
/>
<property
name=
"log.colorPattern"
value=
"%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %boldCyan(${springAppName:-}) %yellow(%thread) %green(%logger) %msg%n"
/>
<property
name=
"log.pattern"
value=
"%d{yyyy-MM-dd HH:mm:ss} %-5level ${springAppName:-} %thread %logger %msg%n"
/>
<!--输出到控制台-->
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<pattern>
${log.colorPattern}
</pattern>
</encoder>
</appender>
<!--输出到文件-->
<!-- RollingFileAppender:滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 -->
<!-- 以下的大概意思是:1.先按日期存日志,日期变了,将前一天的日志文件名重命名为XXX%日期%索引,新的日志仍然是project_info.log -->
<!-- 2.如果日期没有发生变化,但是当前日志的文件大小超过10MB时,对当前日志进行分割 重命名-->
<appender
name=
"file_info"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!--日志文件路径和名称-->
<File>
${log.path}/info/info.log
</File>
<!--是否追加到文件末尾,默认为true-->
<append>
true
</append>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- 日志文件的名字会根据fileNamePattern的值,每隔一段时间改变一次 -->
<!-- 文件名:logs/project_info.2017-12-05.0.log -->
<!-- 注意:SizeAndTimeBasedRollingPolicy中 %i和%d令牌都是强制性的,必须存在,要不会报错 -->
<fileNamePattern>
${log.path}/info/info.%d.%i.log
</fileNamePattern>
<!-- 每产生一个日志文件,该日志文件的保存期限为30天, ps:maxHistory的单位是根据fileNamePattern中的翻转策略自动推算出来的,例如上面选用了yyyy-MM-dd,则单位为天
如果上面选用了yyyy-MM,则单位为月,另外上面的单位默认为yyyy-MM-dd-->
<MaxHistory>
${log.maxHistory}
</MaxHistory>
<!-- 每个日志文件到2mb的时候开始切分,最多保留30天,但最大到500MB,哪怕没到30天也要删除多余的日志 -->
<totalSizeCap>
${log.totalSizeCap}
</totalSizeCap>
<!-- maxFileSize:这是活动文件的大小,默认值是10MB,测试时可改成5KB看效果 -->
<maxFileSize>
${log.maxFileSize}
</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>
${log.pattern}
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<appender
name=
"file_error"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${log.path}/error/error.log
</File>
<append>
true
</append>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<fileNamePattern>
${log.path}/error/error.%d.%i.log
</fileNamePattern>
<MaxHistory>
${log.maxHistory}
</MaxHistory>
<totalSizeCap>
${log.totalSizeCap}
</totalSizeCap>
<maxFileSize>
${log.maxFileSize}
</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>
${log.pattern}
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
</appender>
<root
level=
"debug"
>
<appender-ref
ref=
"console"
/>
</root>
<root
level=
"info"
>
<appender-ref
ref=
"file_info"
/>
<appender-ref
ref=
"file_error"
/>
</root>
</configuration>
\ No newline at end of file
datax-modules/data-standard-service-parent/data-standard-service/src/main/resources/spy.properties
0 → 100644
View file @
ccb828df
module.log
=
com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat
=
com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
appender
=
com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
# 使用日志系统记录 sql
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
deregisterdrivers
=
true
# 取消JDBC URL前缀
useprefix
=
true
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
excludecategories
=
info,debug,result,batch,resultset
# 日期格式
dateformat
=
yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection
=
true
# 慢SQL记录标准 2 秒
outagedetectioninterval
=
2
# 开启过滤
filter
=
true
# 配置不打印的内容
exclude
=
select 1
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment