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
205282c2
Commit
205282c2
authored
Apr 17, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
607171bf
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
64 additions
and
646 deletions
+64
-646
datax-gateway-dev.yml
datax-config/src/main/resources/config/datax-gateway-dev.yml
+0
-13
datax-service-data-masking-dev.yml
.../main/resources/config/datax-service-data-masking-dev.yml
+0
-74
RedisCacheConfig.java
...n/datax/service/data/factory/config/RedisCacheConfig.java
+1
-2
DataSourceController.java
...service/data/factory/controller/DataSourceController.java
+0
-12
DataSourceService.java
...datax/service/data/factory/service/DataSourceService.java
+0
-5
DataSetServiceImpl.java
...service/data/factory/service/impl/DataSetServiceImpl.java
+4
-4
DataSourceServiceImpl.java
...vice/data/factory/service/impl/DataSourceServiceImpl.java
+4
-20
ApiCallServiceImpl.java
...data/market/api/call/service/impl/ApiCallServiceImpl.java
+1
-1
ApiMaskServiceFeign.java
...ax/service/data/market/api/feign/ApiMaskServiceFeign.java
+3
-3
ApiMaskServiceFeignFallbackImpl.java
...t/api/feign/fallback/ApiMaskServiceFeignFallbackImpl.java
+1
-1
pom.xml
...t-service-parent/data-market-service-data-masking/pom.xml
+0
-94
DataMaskingApplication.java
...vice/data/market/data/masking/DataMaskingApplication.java
+0
-22
DataResourceServerConfig.java
.../market/data/masking/config/DataResourceServerConfig.java
+0
-67
RedisCacheConfig.java
...ice/data/market/data/masking/config/RedisCacheConfig.java
+0
-99
SwaggerConfig.java
...ervice/data/market/data/masking/config/SwaggerConfig.java
+0
-104
InnerController.java
.../data/market/data/masking/controller/InnerController.java
+0
-39
bootstrap.yml
...ket-service-data-masking/src/main/resources/bootstrap.yml
+0
-29
spy.properties
...et-service-data-masking/src/main/resources/spy.properties
+0
-26
RedisCacheConfig.java
...cn/datax/service/data/market/config/RedisCacheConfig.java
+2
-3
ApiMaskController.java
...tax/service/data/market/controller/ApiMaskController.java
+5
-6
InnerController.java
...datax/service/data/market/controller/InnerController.java
+23
-0
ApiMaskDao.java
...ain/java/cn/datax/service/data/market/dao/ApiMaskDao.java
+1
-1
ApiMaskMapper.java
...cn/datax/service/data/market/mapstruct/ApiMaskMapper.java
+1
-1
ApiMaskService.java
.../cn/datax/service/data/market/service/ApiMaskService.java
+3
-3
ApiMaskServiceImpl.java
.../service/data/market/service/impl/ApiMaskServiceImpl.java
+10
-10
DataApiServiceImpl.java
.../service/data/market/service/impl/DataApiServiceImpl.java
+4
-4
ApiMaskMapper.xml
...arket-service/src/main/resources/mapper/ApiMaskMapper.xml
+1
-1
pom.xml
datax-modules/data-market-service-parent/pom.xml
+0
-2
No files found.
datax-config/src/main/resources/config/datax-gateway-dev.yml
View file @
205282c2
...
@@ -107,16 +107,4 @@ spring:
...
@@ -107,16 +107,4 @@ spring:
-
name
:
Hystrix
-
name
:
Hystrix
args
:
args
:
name
:
dataSqlConsoleHystrix
name
:
dataSqlConsoleHystrix
fallbackUri
:
forward:/fallback
# 数据脱敏
-
id
:
datax-service-data-masking
uri
:
lb://datax-service-data-masking
predicates
:
-
Path=/data/masking/**
filters
:
-
SwaggerHeaderFilter
-
StripPrefix=2
-
name
:
Hystrix
args
:
name
:
dataMaskingHystrix
fallbackUri
:
forward:/fallback
fallbackUri
:
forward:/fallback
\ No newline at end of file
datax-config/src/main/resources/config/datax-service-data-masking-dev.yml
deleted
100644 → 0
View file @
607171bf
# 数据源配置
spring
:
redis
:
database
:
1
host
:
127.0.0.1
port
:
6379
password
:
# 密码(默认为空)
timeout
:
6000ms
# 连接超时时长(毫秒)
lettuce
:
pool
:
max-active
:
1000
# 连接池最大连接数(使用负值表示没有限制)
max-wait
:
-1ms
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle
:
10
# 连接池中的最大空闲连接
min-idle
:
5
# 连接池中的最小空闲连接
datasource
:
dynamic
:
type
:
com.zaxxer.hikari.HikariDataSource
hikari
:
auto-commit
:
false
connection-timeout
:
30000
idle-timeout
:
25000
login-timeout
:
5
max-lifetime
:
30000
read-only
:
false
validation-timeout
:
3000
maximum-pool-size
:
15
minimum-idle
:
5
pool-name
:
DataxHikariCP
connection-test-query
:
SELECT 1 FROM DUAL
data-source-properties
:
cachePrepStmts
:
true
prepStmtCacheSize
:
250
prepStmtCacheSqlLimit
:
2048
useServerPrepStmts
:
true
useLocalSessionState
:
true
rewriteBatchedStatements
:
true
cacheResultSetMetadata
:
true
cacheServerConfiguration
:
true
elideSetAutoCommits
:
true
maintainTimeStats
:
false
primary
:
mysql
datasource
:
mysql
:
driver-class-name
:
com.p6spy.engine.spy.P6SpyDriver
url
:
jdbc:p6spy:mysql://127.0.0.1:3306/data_cloud?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username
:
root
password
:
1234@abcd
mybatis-plus
:
mapper-locations
:
classpath*:mapper/*Mapper.xml
type-aliases-package
:
cn.datax.service.data.market.api.entity
global-config
:
db-config
:
id-type
:
ASSIGN_ID
banner
:
false
configuration
:
map-underscore-to-camel-case
:
true
cache-enabled
:
false
call-setters-on-nulls
:
true
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
# spring security 配置
security
:
oauth2
:
client
:
access-token-uri
:
http://localhost:8612/auth/oauth/token
user-authorization-uri
:
http://localhost:8612/auth/oauth/authorize
client-id
:
datax
client-secret
:
123456
scope
:
all
resource
:
loadBalanced
:
true
token-info-uri
:
http://localhost:8612/auth/oauth/check_token
\ No newline at end of file
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/config/RedisCacheConfig.java
View file @
205282c2
...
@@ -74,13 +74,12 @@ public class RedisCacheConfig extends CachingConfigurerSupport {
...
@@ -74,13 +74,12 @@ public class RedisCacheConfig extends CachingConfigurerSupport {
}
}
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
)
{
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
)
{
Jackson2JsonRedisSerializer
<
Object
>
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
// 解决jackson2无法反序列化LocalDateTime的问题
// 解决jackson2无法反序列化LocalDateTime的问题
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
JavaTimeModule
javaTimeModule
=
new
JavaTimeModule
();
JavaTimeModule
javaTimeModule
=
new
JavaTimeModule
();
javaTimeModule
.
addSerializer
(
LocalDateTime
.
class
,
new
LocalDateTimeSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
javaTimeModule
.
addSerializer
(
LocalDateTime
.
class
,
new
LocalDateTimeSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
javaTimeModule
.
addSerializer
(
LocalDate
.
class
,
new
LocalDateSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
javaTimeModule
.
addSerializer
(
LocalDate
.
class
,
new
LocalDateSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/controller/DataSourceController.java
View file @
205282c2
...
@@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.*;
...
@@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.*;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.base.BaseController
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -124,17 +123,6 @@ public class DataSourceController extends BaseController {
...
@@ -124,17 +123,6 @@ public class DataSourceController extends BaseController {
}
}
/**
/**
* 数据库类型
* @return
*/
@ApiOperation
(
value
=
"数据库类型"
,
notes
=
"获取数据库类型"
)
@GetMapping
(
"/dbTypes"
)
public
R
getDbTypes
()
{
List
<
Map
<
String
,
Object
>>
dbTypes
=
dataSourceService
.
getDbTypes
();
return
R
.
ok
().
setData
(
dbTypes
);
}
/**
* 检测数据库连通性
* 检测数据库连通性
* @param dataSource
* @param dataSource
* @return
* @return
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/DataSourceService.java
View file @
205282c2
...
@@ -5,9 +5,6 @@ import cn.datax.service.data.factory.api.dto.DataSourceDto;
...
@@ -5,9 +5,6 @@ import cn.datax.service.data.factory.api.dto.DataSourceDto;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.common.base.BaseService
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* <p>
* <p>
* 数据源信息表 服务类
* 数据源信息表 服务类
...
@@ -26,7 +23,5 @@ public interface DataSourceService extends BaseService<DataSourceEntity> {
...
@@ -26,7 +23,5 @@ public interface DataSourceService extends BaseService<DataSourceEntity> {
DbQuery
checkConnection
(
DataSourceDto
dataSource
);
DbQuery
checkConnection
(
DataSourceDto
dataSource
);
List
<
Map
<
String
,
Object
>>
getDbTypes
();
DbQuery
getDbQuery
(
String
id
);
DbQuery
getDbQuery
(
String
id
);
}
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/impl/DataSetServiceImpl.java
View file @
205282c2
...
@@ -25,7 +25,7 @@ import java.io.Serializable;
...
@@ -25,7 +25,7 @@ import java.io.Serializable;
* @author yuwei
* @author yuwei
* @since 2020-03-20
* @since 2020-03-20
*/
*/
@CacheConfig
(
cacheNames
=
"data:factory:sets"
)
//
@CacheConfig(cacheNames = "data:factory:sets")
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DataSetServiceImpl
extends
BaseServiceImpl
<
DataSetDao
,
DataSetEntity
>
implements
DataSetService
{
public
class
DataSetServiceImpl
extends
BaseServiceImpl
<
DataSetDao
,
DataSetEntity
>
implements
DataSetService
{
...
@@ -43,7 +43,7 @@ public class DataSetServiceImpl extends BaseServiceImpl<DataSetDao, DataSetEntit
...
@@ -43,7 +43,7 @@ public class DataSetServiceImpl extends BaseServiceImpl<DataSetDao, DataSetEntit
dataSetDao
.
insert
(
dataSet
);
dataSetDao
.
insert
(
dataSet
);
}
}
@CachePut
(
key
=
"#p0.id"
)
//
@CachePut(key = "#p0.id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataSet
(
DataSetDto
dataSetDto
)
{
public
void
updateDataSet
(
DataSetDto
dataSetDto
)
{
...
@@ -51,13 +51,13 @@ public class DataSetServiceImpl extends BaseServiceImpl<DataSetDao, DataSetEntit
...
@@ -51,13 +51,13 @@ public class DataSetServiceImpl extends BaseServiceImpl<DataSetDao, DataSetEntit
dataSetDao
.
updateById
(
dataSet
);
dataSetDao
.
updateById
(
dataSet
);
}
}
@Cacheable
(
key
=
"#id"
,
unless
=
"#result == null"
)
//
@Cacheable(key = "#id", unless = "#result == null")
@Override
@Override
public
DataSetEntity
getById
(
Serializable
id
)
{
public
DataSetEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
return
super
.
getById
(
id
);
}
}
@CacheEvict
(
key
=
"#id"
)
//
@CacheEvict(key = "#id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteDataSetById
(
String
id
)
{
public
void
deleteDataSetById
(
String
id
)
{
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/impl/DataSourceServiceImpl.java
View file @
205282c2
...
@@ -3,7 +3,6 @@ package cn.datax.service.data.factory.service.impl;
...
@@ -3,7 +3,6 @@ package cn.datax.service.data.factory.service.impl;
import
cn.datax.common.database.DataSourceFactory
;
import
cn.datax.common.database.DataSourceFactory
;
import
cn.datax.common.database.DbQuery
;
import
cn.datax.common.database.DbQuery
;
import
cn.datax.common.database.constants.DbQueryProperty
;
import
cn.datax.common.database.constants.DbQueryProperty
;
import
cn.datax.common.database.constants.DbType
;
import
cn.datax.service.data.factory.api.dto.DataSourceDto
;
import
cn.datax.service.data.factory.api.dto.DataSourceDto
;
import
cn.datax.service.data.factory.api.dto.DbSchema
;
import
cn.datax.service.data.factory.api.dto.DbSchema
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
...
@@ -21,11 +20,6 @@ import org.springframework.transaction.annotation.Propagation;
...
@@ -21,11 +20,6 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* <p>
* <p>
...
@@ -35,7 +29,7 @@ import java.util.stream.Collectors;
...
@@ -35,7 +29,7 @@ import java.util.stream.Collectors;
* @author yuwei
* @author yuwei
* @since 2020-03-14
* @since 2020-03-14
*/
*/
@CacheConfig
(
cacheNames
=
"data:factory:sources"
)
//
@CacheConfig(cacheNames = "data:factory:sources")
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DataSourceServiceImpl
extends
BaseServiceImpl
<
DataSourceDao
,
DataSourceEntity
>
implements
DataSourceService
{
public
class
DataSourceServiceImpl
extends
BaseServiceImpl
<
DataSourceDao
,
DataSourceEntity
>
implements
DataSourceService
{
...
@@ -56,7 +50,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
...
@@ -56,7 +50,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
dataSourceDao
.
insert
(
dataSource
);
dataSourceDao
.
insert
(
dataSource
);
}
}
@CachePut
(
key
=
"#p0.id"
)
//
@CachePut(key = "#p0.id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataSource
(
DataSourceDto
dataSourceDto
)
{
public
void
updateDataSource
(
DataSourceDto
dataSourceDto
)
{
...
@@ -64,13 +58,13 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
...
@@ -64,13 +58,13 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
dataSourceDao
.
updateById
(
dataSource
);
dataSourceDao
.
updateById
(
dataSource
);
}
}
@Cacheable
(
key
=
"#id"
,
unless
=
"#result == null"
)
//
@Cacheable(key = "#id", unless = "#result == null")
@Override
@Override
public
DataSourceEntity
getById
(
Serializable
id
)
{
public
DataSourceEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
return
super
.
getById
(
id
);
}
}
@CacheEvict
(
key
=
"#id"
)
//
@CacheEvict(key = "#id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteDataSourceById
(
String
id
)
{
public
void
deleteDataSourceById
(
String
id
)
{
...
@@ -88,16 +82,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
...
@@ -88,16 +82,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
}
}
@Override
@Override
public
List
<
Map
<
String
,
Object
>>
getDbTypes
()
{
return
Arrays
.
stream
(
DbType
.
values
()).
map
(
s
->
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
s
.
getDb
());
map
.
put
(
"name"
,
s
.
getDesc
());
return
map
;
}).
collect
(
Collectors
.
toList
());
}
@Override
public
DbQuery
getDbQuery
(
String
id
)
{
public
DbQuery
getDbQuery
(
String
id
)
{
DataSourceEntity
dataSource
=
getById
(
id
);
DataSourceEntity
dataSource
=
getById
(
id
);
DbSchema
dbSchema
=
dataSource
.
getDbSchema
();
DbSchema
dbSchema
=
dataSource
.
getDbSchema
();
...
...
datax-modules/data-market-service-parent/data-market-service-api-call/src/main/java/cn/datax/service/data/market/api/call/service/impl/ApiCallServiceImpl.java
View file @
205282c2
...
@@ -88,7 +88,7 @@ public class ApiCallServiceImpl implements ApiCallService {
...
@@ -88,7 +88,7 @@ public class ApiCallServiceImpl implements ApiCallService {
Map
<
String
,
Object
>
acceptedFilters
=
sqlFilterResult
.
getAcceptedFilters
();
Map
<
String
,
Object
>
acceptedFilters
=
sqlFilterResult
.
getAcceptedFilters
();
// 数据脱敏
// 数据脱敏
List
<
FieldRule
>
rules
=
null
;
List
<
FieldRule
>
rules
=
null
;
R
maskResult
=
apiMaskServiceFeign
.
getApiMaskById
(
ThreadUtil
.
getInstance
().
get
().
getApiId
());
R
maskResult
=
apiMaskServiceFeign
.
getApiMaskBy
Api
Id
(
ThreadUtil
.
getInstance
().
get
().
getApiId
());
if
(
maskResult
!=
null
&&
maskResult
.
isSuccess
()
&&
ObjectUtil
.
isNotEmpty
(
maskResult
.
getData
())){
if
(
maskResult
!=
null
&&
maskResult
.
isSuccess
()
&&
ObjectUtil
.
isNotEmpty
(
maskResult
.
getData
())){
ApiMaskEntity
apiMask
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
maskResult
.
getData
()),
ApiMaskEntity
.
class
);
ApiMaskEntity
apiMask
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
maskResult
.
getData
()),
ApiMaskEntity
.
class
);
rules
=
apiMask
.
getRules
();
rules
=
apiMask
.
getRules
();
...
...
datax-modules/data-market-service-parent/data-market-service-api/src/main/java/cn/datax/service/data/market/api/feign/ApiMaskServiceFeign.java
View file @
205282c2
...
@@ -6,9 +6,9 @@ import org.springframework.cloud.openfeign.FeignClient;
...
@@ -6,9 +6,9 @@ import org.springframework.cloud.openfeign.FeignClient;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
@FeignClient
(
contextId
=
"apiMaskServiceFeign"
,
value
=
"datax-service-data-ma
sking
"
,
fallbackFactory
=
ApiMaskServiceFeignFallbackFactory
.
class
)
@FeignClient
(
contextId
=
"apiMaskServiceFeign"
,
value
=
"datax-service-data-ma
rket
"
,
fallbackFactory
=
ApiMaskServiceFeignFallbackFactory
.
class
)
public
interface
ApiMaskServiceFeign
{
public
interface
ApiMaskServiceFeign
{
@GetMapping
(
"/inner/apiMask/{
i
d}"
)
@GetMapping
(
"/inner/apiMask/{
apiI
d}"
)
R
getApiMaskBy
Id
(
@PathVariable
(
"id"
)
String
i
d
);
R
getApiMaskBy
ApiId
(
@PathVariable
(
"apiId"
)
String
apiI
d
);
}
}
datax-modules/data-market-service-parent/data-market-service-api/src/main/java/cn/datax/service/data/market/api/feign/fallback/ApiMaskServiceFeignFallbackImpl.java
View file @
205282c2
...
@@ -14,7 +14,7 @@ public class ApiMaskServiceFeignFallbackImpl implements ApiMaskServiceFeign {
...
@@ -14,7 +14,7 @@ public class ApiMaskServiceFeignFallbackImpl implements ApiMaskServiceFeign {
private
Throwable
cause
;
private
Throwable
cause
;
@Override
@Override
public
R
getApiMaskById
(
String
id
)
{
public
R
getApiMaskBy
Api
Id
(
String
id
)
{
log
.
error
(
"feign 调用{}出错"
,
id
,
cause
);
log
.
error
(
"feign 调用{}出错"
,
id
,
cause
);
return
null
;
return
null
;
}
}
...
...
datax-modules/data-market-service-parent/data-market-service-data-masking/pom.xml
deleted
100644 → 0
View file @
607171bf
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
data-market-service-parent
</artifactId>
<groupId>
cn.datax
</groupId>
<version>
2.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<version>
2.0.0
</version>
<description>
数据脱敏
</description>
<artifactId>
data-market-service-data-masking
</artifactId>
<dependencies>
<!--web 模块-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<exclusions>
<exclusion>
<artifactId>
spring-boot-starter-tomcat
</artifactId>
<groupId>
org.springframework.boot
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-undertow
</artifactId>
</dependency>
<!--配置中心客户端 -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct
</artifactId>
<version>
${mapstruct.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
${mapstruct.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
datax-common-mybatis
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
datax-common-redis
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
datax-common-security
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
datax-common-database
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
datax-common-log
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
system-service-api
</artifactId>
<version>
2.0.0
</version>
</dependency>
<dependency>
<groupId>
cn.datax
</groupId>
<artifactId>
data-market-service-api
</artifactId>
<version>
2.0.0
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
datax-modules/data-market-service-parent/data-market-service-data-masking/src/main/java/cn/datax/service/data/market/data/masking/DataMaskingApplication.java
deleted
100644 → 0
View file @
607171bf
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
;
import
cn.datax.common.log.annotation.EnableDataLog
;
import
cn.datax.common.mybatis.annotation.EnableDataMybatis
;
import
cn.datax.common.redis.annotation.EnableDataRedis
;
import
cn.datax.common.security.annotation.EnableDataServerProtect
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableDataServerProtect
@EnableDataMybatis
@EnableDataRedis
@EnableDataLog
@EnableFeignClients
(
basePackages
=
{
"cn.datax.service.system.api.feign"
,
"cn.datax.service.data.market.api.feign"
})
@SpringCloudApplication
public
class
DataMaskingApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DataMaskingApplication
.
class
);
}
}
datax-modules/data-market-service-parent/data-market-service-data-masking/src/main/java/cn/datax/service/data/market/data/masking/config/DataResourceServerConfig.java
deleted
100644 → 0
View file @
607171bf
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
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/**"
,
// API调用
"/v1/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
().
csrf
().
disable
();
}
}
datax-modules/data-market-service-parent/data-market-service-data-masking/src/main/java/cn/datax/service/data/market/data/masking/config/RedisCacheConfig.java
deleted
100644 → 0
View file @
607171bf
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.annotation.CachingConfigurerSupport
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.cache.RedisCacheWriter
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializationContext
;
import
java.lang.reflect.Method
;
import
java.time.Duration
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashMap
;
import
java.util.Map
;
@Configuration
@EnableCaching
public
class
RedisCacheConfig
extends
CachingConfigurerSupport
{
/**
* 在没有指定缓存Key的情况下,key生成策略
* @return
*/
@Bean
public
KeyGenerator
keyGenerator
()
{
return
new
KeyGenerator
()
{
@Override
public
Object
generate
(
Object
target
,
Method
method
,
Object
...
params
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
target
.
getClass
().
getName
());
sb
.
append
(
"#"
+
method
.
getName
());
for
(
Object
obj
:
params
)
{
sb
.
append
(
obj
.
toString
());
}
return
sb
.
toString
();
}
};
}
@Bean
public
CacheManager
cacheManager
(
RedisConnectionFactory
redisConnectionFactory
)
{
return
new
RedisCacheManager
(
RedisCacheWriter
.
nonLockingRedisCacheWriter
(
redisConnectionFactory
),
this
.
redisCacheConfigurationWithTtl
(
30
),
this
.
redisCacheConfigurationMap
()
);
}
private
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
()
{
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
=
new
HashMap
<>();
redisCacheConfigurationMap
.
put
(
"data:api:masks"
,
redisCacheConfigurationWithTtl
(
30
));
return
redisCacheConfigurationMap
;
}
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
)
{
Jackson2JsonRedisSerializer
<
Object
>
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
// 解决jackson2无法反序列化LocalDateTime的问题
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
JavaTimeModule
javaTimeModule
=
new
JavaTimeModule
();
javaTimeModule
.
addSerializer
(
LocalDateTime
.
class
,
new
LocalDateTimeSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
javaTimeModule
.
addSerializer
(
LocalDate
.
class
,
new
LocalDateSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
javaTimeModule
.
addSerializer
(
LocalTime
.
class
,
new
LocalTimeSerializer
(
DateTimeFormatter
.
ofPattern
(
"HH:mm:ss"
)));
javaTimeModule
.
addDeserializer
(
LocalDateTime
.
class
,
new
LocalDateTimeDeserializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
javaTimeModule
.
addDeserializer
(
LocalDate
.
class
,
new
LocalDateDeserializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
javaTimeModule
.
addDeserializer
(
LocalTime
.
class
,
new
LocalTimeDeserializer
(
DateTimeFormatter
.
ofPattern
(
"HH:mm:ss"
)));
om
.
registerModule
(
javaTimeModule
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
om
);
RedisCacheConfiguration
redisCacheConfiguration
=
RedisCacheConfiguration
.
defaultCacheConfig
();
redisCacheConfiguration
=
redisCacheConfiguration
.
serializeValuesWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
jackson2JsonRedisSerializer
)
).
entryTtl
(
Duration
.
ofMinutes
(
minutes
));
return
redisCacheConfiguration
;
}
}
\ No newline at end of file
datax-modules/data-market-service-parent/data-market-service-data-masking/src/main/java/cn/datax/service/data/market/data/masking/config/SwaggerConfig.java
deleted
100644 → 0
View file @
607171bf
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
springfox.documentation.builders.*
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.ApiKey
;
import
springfox.documentation.service.Parameter
;
import
springfox.documentation.service.ResponseMessage
;
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
@EnableSwagger2
public
class
SwaggerConfig
{
/**
* 创建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
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"cn.datax.service.data.market.data.masking.controller"
))
//扫描该包下面的API注解
.
paths
(
PathSelectors
.
any
())
.
build
()
//设置安全认证
.
securitySchemes
(
security
());
}
/**
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
* 访问地址:http://项目实际地址/swagger-ui.html
* @return
*/
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"数据市场管理中心"
)
//接口管理文档首页显示
.
description
(
"数据市场管理中心接口文档"
)
//API的描述
.
version
(
"1.0"
)
.
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-market-service-parent/data-market-service-data-masking/src/main/java/cn/datax/service/data/market/data/masking/controller/InnerController.java
deleted
100644 → 0
View file @
607171bf
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
controller
;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.R
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.data.masking.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.data.masking.service.ApiMaskService
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/inner"
)
public
class
InnerController
extends
BaseController
{
@Autowired
private
ApiMaskService
apiMaskService
;
@Autowired
private
ApiMaskMapper
apiMaskMapper
;
/**
* 通过ID查询信息
*
* @param id
* @return
*/
@ApiOperation
(
value
=
"获取详细信息"
,
notes
=
"根据url的id来获取详细信息"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/apiMask/{id}"
)
public
R
getApiMaskById
(
@PathVariable
String
id
)
{
ApiMaskEntity
apiMaskEntity
=
apiMaskService
.
getById
(
id
);
return
R
.
ok
().
setData
(
apiMaskMapper
.
toVO
(
apiMaskEntity
));
}
}
datax-modules/data-market-service-parent/data-market-service-data-masking/src/main/resources/bootstrap.yml
deleted
100644 → 0
View file @
607171bf
server
:
port
:
8817
spring
:
application
:
name
:
datax-service-data-masking
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-market-service-parent/data-market-service-data-masking/src/main/resources/spy.properties
deleted
100644 → 0
View file @
607171bf
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-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/config/RedisCacheConfig.java
View file @
205282c2
...
@@ -59,7 +59,6 @@ public class RedisCacheConfig extends CachingConfigurerSupport {
...
@@ -59,7 +59,6 @@ public class RedisCacheConfig extends CachingConfigurerSupport {
@Bean
@Bean
public
CacheManager
cacheManager
(
RedisConnectionFactory
redisConnectionFactory
)
{
public
CacheManager
cacheManager
(
RedisConnectionFactory
redisConnectionFactory
)
{
return
new
RedisCacheManager
(
return
new
RedisCacheManager
(
RedisCacheWriter
.
nonLockingRedisCacheWriter
(
redisConnectionFactory
),
RedisCacheWriter
.
nonLockingRedisCacheWriter
(
redisConnectionFactory
),
this
.
redisCacheConfigurationWithTtl
(
30
),
this
.
redisCacheConfigurationWithTtl
(
30
),
...
@@ -70,17 +69,17 @@ public class RedisCacheConfig extends CachingConfigurerSupport {
...
@@ -70,17 +69,17 @@ public class RedisCacheConfig extends CachingConfigurerSupport {
private
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
()
{
private
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
()
{
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
=
new
HashMap
<>();
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
=
new
HashMap
<>();
redisCacheConfigurationMap
.
put
(
"data:market:apis"
,
redisCacheConfigurationWithTtl
(
30
));
redisCacheConfigurationMap
.
put
(
"data:market:apis"
,
redisCacheConfigurationWithTtl
(
30
));
redisCacheConfigurationMap
.
put
(
"data:market:api:masks"
,
redisCacheConfigurationWithTtl
(
30
));
return
redisCacheConfigurationMap
;
return
redisCacheConfigurationMap
;
}
}
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
)
{
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
)
{
Jackson2JsonRedisSerializer
<
Object
>
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
// 解决jackson2无法反序列化LocalDateTime的问题
// 解决jackson2无法反序列化LocalDateTime的问题
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
JavaTimeModule
javaTimeModule
=
new
JavaTimeModule
();
JavaTimeModule
javaTimeModule
=
new
JavaTimeModule
();
javaTimeModule
.
addSerializer
(
LocalDateTime
.
class
,
new
LocalDateTimeSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
javaTimeModule
.
addSerializer
(
LocalDateTime
.
class
,
new
LocalDateTimeSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
javaTimeModule
.
addSerializer
(
LocalDate
.
class
,
new
LocalDateSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
javaTimeModule
.
addSerializer
(
LocalDate
.
class
,
new
LocalDateSerializer
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
...
...
datax-modules/data-market-service-parent/data-market-service
-data-masking/src/main/java/cn/datax/service/data/market/data/masking
/controller/ApiMaskController.java
→
datax-modules/data-market-service-parent/data-market-service
/src/main/java/cn/datax/service/data/market
/controller/ApiMaskController.java
View file @
205282c2
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
controller
;
package
cn
.
datax
.
service
.
data
.
market
.
controller
;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.R
;
import
cn.datax.common.core.R
;
import
cn.datax.common.validate.ValidationGroups
;
import
cn.datax.common.validate.ValidationGroups
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.api.vo.ApiMaskVo
;
import
cn.datax.service.data.market.api.query.ApiMaskQuery
;
import
cn.datax.service.data.market.api.query.ApiMaskQuery
;
import
cn.datax.service.data.market.data.masking.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.api.vo.ApiMaskVo
;
import
cn.datax.service.data.market.data.masking.service.ApiMaskService
;
import
cn.datax.service.data.market.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.service.ApiMaskService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
@@ -20,8 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -20,8 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
cn.datax.common.base.BaseController
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
...
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/InnerController.java
View file @
205282c2
...
@@ -3,9 +3,13 @@ package cn.datax.service.data.market.controller;
...
@@ -3,9 +3,13 @@ package cn.datax.service.data.market.controller;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.R
;
import
cn.datax.common.core.R
;
import
cn.datax.common.security.annotation.DataInner
;
import
cn.datax.common.security.annotation.DataInner
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.api.entity.DataApiEntity
;
import
cn.datax.service.data.market.api.entity.DataApiEntity
;
import
cn.datax.service.data.market.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.mapstruct.DataApiMapper
;
import
cn.datax.service.data.market.mapstruct.DataApiMapper
;
import
cn.datax.service.data.market.service.ApiMaskService
;
import
cn.datax.service.data.market.service.DataApiService
;
import
cn.datax.service.data.market.service.DataApiService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
@@ -22,6 +26,12 @@ public class InnerController extends BaseController {
...
@@ -22,6 +26,12 @@ public class InnerController extends BaseController {
@Autowired
@Autowired
private
DataApiMapper
dataApiMapper
;
private
DataApiMapper
dataApiMapper
;
@Autowired
private
ApiMaskService
apiMaskService
;
@Autowired
private
ApiMaskMapper
apiMaskMapper
;
/**
/**
* 通过ID查询信息
* 通过ID查询信息
*
*
...
@@ -34,4 +44,17 @@ public class InnerController extends BaseController {
...
@@ -34,4 +44,17 @@ public class InnerController extends BaseController {
DataApiEntity
dataApiEntity
=
dataApiService
.
getById
(
id
);
DataApiEntity
dataApiEntity
=
dataApiService
.
getById
(
id
);
return
R
.
ok
().
setData
(
dataApiMapper
.
toVO
(
dataApiEntity
));
return
R
.
ok
().
setData
(
dataApiMapper
.
toVO
(
dataApiEntity
));
}
}
/**
* 通过ID查询信息
*
* @param apiId
* @return
*/
@DataInner
@GetMapping
(
"/apiMask/{apiId}"
)
public
R
getApiMaskByApiId
(
@PathVariable
String
apiId
)
{
ApiMaskEntity
apiMaskEntity
=
apiMaskService
.
getOne
(
new
QueryWrapper
<
ApiMaskEntity
>().
eq
(
"api_id"
,
apiId
));
return
R
.
ok
().
setData
(
apiMaskMapper
.
toVO
(
apiMaskEntity
));
}
}
}
datax-modules/data-market-service-parent/data-market-service
-data-masking/src/main/java/cn/datax/service/data/market/data/masking
/dao/ApiMaskDao.java
→
datax-modules/data-market-service-parent/data-market-service
/src/main/java/cn/datax/service/data/market
/dao/ApiMaskDao.java
View file @
205282c2
package
cn
.
datax
.
service
.
data
.
market
.
da
ta
.
masking
.
da
o
;
package
cn
.
datax
.
service
.
data
.
market
.
dao
;
import
cn.datax.common.base.BaseDao
;
import
cn.datax.common.base.BaseDao
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
...
...
datax-modules/data-market-service-parent/data-market-service
-data-masking/src/main/java/cn/datax/service/data/market/data/masking
/mapstruct/ApiMaskMapper.java
→
datax-modules/data-market-service-parent/data-market-service
/src/main/java/cn/datax/service/data/market
/mapstruct/ApiMaskMapper.java
View file @
205282c2
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
mapstruct
;
package
cn
.
datax
.
service
.
data
.
market
.
mapstruct
;
import
cn.datax.common.mapstruct.EntityMapper
;
import
cn.datax.common.mapstruct.EntityMapper
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
...
...
datax-modules/data-market-service-parent/data-market-service
-data-masking/src/main/java/cn/datax/service/data/market/data/masking
/service/ApiMaskService.java
→
datax-modules/data-market-service-parent/data-market-service
/src/main/java/cn/datax/service/data/market
/service/ApiMaskService.java
View file @
205282c2
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
service
;
package
cn
.
datax
.
service
.
data
.
market
.
service
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
/**
/**
* <p>
* <p>
...
...
datax-modules/data-market-service-parent/data-market-service
-data-masking/src/main/java/cn/datax/service/data/market/data/masking
/service/impl/ApiMaskServiceImpl.java
→
datax-modules/data-market-service-parent/data-market-service
/src/main/java/cn/datax/service/data/market
/service/impl/ApiMaskServiceImpl.java
View file @
205282c2
package
cn
.
datax
.
service
.
data
.
market
.
data
.
masking
.
service
.
impl
;
package
cn
.
datax
.
service
.
data
.
market
.
service
.
impl
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.service.data.market.data.masking.service.ApiMaskService
;
import
cn.datax.service.data.market.data.masking.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.data.masking.dao.ApiMaskDao
;
import
cn.datax.common.base.BaseServiceImpl
;
import
cn.datax.common.base.BaseServiceImpl
;
import
cn.datax.service.data.market.api.dto.ApiMaskDto
;
import
cn.datax.service.data.market.api.entity.ApiMaskEntity
;
import
cn.datax.service.data.market.dao.ApiMaskDao
;
import
cn.datax.service.data.market.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.service.ApiMaskService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CacheEvict
;
...
@@ -25,7 +25,7 @@ import java.io.Serializable;
...
@@ -25,7 +25,7 @@ import java.io.Serializable;
* @author yuwei
* @author yuwei
* @since 2020-04-14
* @since 2020-04-14
*/
*/
@CacheConfig
(
cacheNames
=
"data:api:masks"
)
//
@CacheConfig(cacheNames = "data:api:masks")
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
ApiMaskServiceImpl
extends
BaseServiceImpl
<
ApiMaskDao
,
ApiMaskEntity
>
implements
ApiMaskService
{
public
class
ApiMaskServiceImpl
extends
BaseServiceImpl
<
ApiMaskDao
,
ApiMaskEntity
>
implements
ApiMaskService
{
...
@@ -43,7 +43,7 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
...
@@ -43,7 +43,7 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
apiMaskDao
.
insert
(
apiMask
);
apiMaskDao
.
insert
(
apiMask
);
}
}
@CachePut
(
key
=
"#p0.id"
)
//
@CachePut(key = "#p0.id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateApiMask
(
ApiMaskDto
apiMaskDto
)
{
public
void
updateApiMask
(
ApiMaskDto
apiMaskDto
)
{
...
@@ -51,13 +51,13 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
...
@@ -51,13 +51,13 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
apiMaskDao
.
updateById
(
apiMask
);
apiMaskDao
.
updateById
(
apiMask
);
}
}
@Cacheable
(
key
=
"#id"
)
//
@Cacheable(key = "#id")
@Override
@Override
public
ApiMaskEntity
getById
(
Serializable
id
)
{
public
ApiMaskEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
return
super
.
getById
(
id
);
}
}
@CacheEvict
(
key
=
"#id"
)
//
@CacheEvict(key = "#id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteApiMaskById
(
String
id
)
{
public
void
deleteApiMaskById
(
String
id
)
{
...
...
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/service/impl/DataApiServiceImpl.java
View file @
205282c2
...
@@ -48,8 +48,8 @@ import java.util.stream.Collectors;
...
@@ -48,8 +48,8 @@ import java.util.stream.Collectors;
* @author yuwei
* @author yuwei
* @since 2020-03-31
* @since 2020-03-31
*/
*/
//@CacheConfig(cacheNames = "data:market:apis")
@Slf4j
@Slf4j
@CacheConfig
(
cacheNames
=
"data:market:apis"
)
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DataApiServiceImpl
extends
BaseServiceImpl
<
DataApiDao
,
DataApiEntity
>
implements
DataApiService
{
public
class
DataApiServiceImpl
extends
BaseServiceImpl
<
DataApiDao
,
DataApiEntity
>
implements
DataApiService
{
...
@@ -67,7 +67,7 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
...
@@ -67,7 +67,7 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
dataApiDao
.
insert
(
dataApi
);
dataApiDao
.
insert
(
dataApi
);
}
}
@CachePut
(
key
=
"#p0.id"
)
//
@CachePut(key = "#p0.id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataApi
(
DataApiDto
dataApiDto
)
{
public
void
updateDataApi
(
DataApiDto
dataApiDto
)
{
...
@@ -89,13 +89,13 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
...
@@ -89,13 +89,13 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
return
dataApi
;
return
dataApi
;
}
}
@Cacheable
(
key
=
"#id"
,
unless
=
"#result == null"
)
//
@Cacheable(key = "#id", unless = "#result == null")
@Override
@Override
public
DataApiEntity
getById
(
Serializable
id
)
{
public
DataApiEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
return
super
.
getById
(
id
);
}
}
@CacheEvict
(
key
=
"#id"
)
//
@CacheEvict(key = "#id")
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteDataApiById
(
String
id
)
{
public
void
deleteDataApiById
(
String
id
)
{
...
...
datax-modules/data-market-service-parent/data-market-service
-data-masking
/src/main/resources/mapper/ApiMaskMapper.xml
→
datax-modules/data-market-service-parent/data-market-service/src/main/resources/mapper/ApiMaskMapper.xml
View file @
205282c2
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.datax.service.data.market.da
ta.masking.da
o.ApiMaskDao"
>
<mapper
namespace=
"cn.datax.service.data.market.dao.ApiMaskDao"
>
<!-- 通用查询映射结果 -->
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.datax.service.data.market.api.entity.ApiMaskEntity"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.datax.service.data.market.api.entity.ApiMaskEntity"
>
...
...
datax-modules/data-market-service-parent/pom.xml
View file @
205282c2
...
@@ -17,6 +17,5 @@
...
@@ -17,6 +17,5 @@
<module>
data-market-service
</module>
<module>
data-market-service
</module>
<module>
data-market-service-api
</module>
<module>
data-market-service-api
</module>
<module>
data-market-service-api-call
</module>
<module>
data-market-service-api-call
</module>
<module>
data-market-service-data-masking
</module>
</modules>
</modules>
</project>
</project>
\ 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