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
8d379f97
Commit
8d379f97
authored
Apr 18, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
a70cc846
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
62 additions
and
258 deletions
+62
-258
RedisConfig.java
...c/main/java/cn/datax/common/redis/config/RedisConfig.java
+8
-20
RedisCacheConfig.java
...n/datax/service/data/factory/config/RedisCacheConfig.java
+0
-69
DataSetController.java
...ax/service/data/factory/controller/DataSetController.java
+2
-2
DataSourceController.java
...service/data/factory/controller/DataSourceController.java
+2
-2
InnerController.java
...atax/service/data/factory/controller/InnerController.java
+3
-7
DataSetService.java
...cn/datax/service/data/factory/service/DataSetService.java
+3
-0
DataSourceService.java
...datax/service/data/factory/service/DataSourceService.java
+3
-0
DataSetServiceImpl.java
...service/data/factory/service/impl/DataSetServiceImpl.java
+4
-12
DataSourceServiceImpl.java
...vice/data/factory/service/impl/DataSourceServiceImpl.java
+4
-10
RedisCacheConfig.java
...cn/datax/service/data/market/config/RedisCacheConfig.java
+0
-94
ApiMaskController.java
...tax/service/data/market/controller/ApiMaskController.java
+2
-2
DataApiController.java
...tax/service/data/market/controller/DataApiController.java
+2
-2
InnerController.java
...datax/service/data/market/controller/InnerController.java
+6
-15
ApiMaskService.java
.../cn/datax/service/data/market/service/ApiMaskService.java
+5
-0
DataApiService.java
.../cn/datax/service/data/market/service/DataApiService.java
+3
-0
ApiMaskServiceImpl.java
.../service/data/market/service/impl/ApiMaskServiceImpl.java
+11
-12
DataApiServiceImpl.java
.../service/data/market/service/impl/DataApiServiceImpl.java
+4
-11
No files found.
datax-common/datax-common-redis/src/main/java/cn/datax/common/redis/config/RedisConfig.java
View file @
8d379f97
...
...
@@ -19,8 +19,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.*
;
import
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
java.time.LocalDate
;
...
...
@@ -32,12 +31,12 @@ import java.time.format.DateTimeFormatter;
public
class
RedisConfig
{
/**
*
自定义redis序列化的机制,重新定义一个ObjectMapper.防止和MVC的冲突
*
实例化 RedisTemplate 对象
*
* @return
*/
@Bean
public
Redis
Serializer
<
Object
>
redisSerializer
(
)
{
public
Redis
Template
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
//使用JSR310提供的序列化类,里面包含了大量的JDK8时间序列化类
...
...
@@ -60,24 +59,13 @@ public class RedisConfig {
objectMapper
.
configure
(
SerializationFeature
.
WRITE_DATE_KEYS_AS_TIMESTAMPS
,
false
);
//启用反序列化所需的类型信息,在属性中添加@class
objectMapper
.
activateDefaultTyping
(
LaissezFaireSubTypeValidator
.
instance
,
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
//配置null值的序列化器
GenericJackson2JsonRedisSerializer
.
registerNullValueSerializer
(
objectMapper
,
null
);
return
new
GenericJackson2JsonRedisSerializer
(
objectMapper
);
}
/**
* 实例化 RedisTemplate 对象
*
* @return
*/
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
redisConnectionFactory
,
RedisSerializer
<
Object
>
redisSerializer
)
{
Jackson2JsonRedisSerializer
<
Object
>
serializer
=
new
Jackson2JsonRedisSerializer
<
Object
>(
Object
.
class
);
serializer
.
setObjectMapper
(
objectMapper
);
RedisTemplate
<
String
,
Object
>
redisTemplate
=
new
RedisTemplate
<>();
redisTemplate
.
setDefaultSerializer
(
redisSerializer
);
redisTemplate
.
setConnectionFactory
(
redisConnectionFactory
);
redisTemplate
.
setDefaultSerializer
(
redisS
erializer
);
redisTemplate
.
setValueSerializer
(
redisS
erializer
);
redisTemplate
.
setHashValueSerializer
(
redisS
erializer
);
redisTemplate
.
setDefaultSerializer
(
s
erializer
);
redisTemplate
.
setValueSerializer
(
s
erializer
);
redisTemplate
.
setHashValueSerializer
(
s
erializer
);
redisTemplate
.
setKeySerializer
(
StringRedisSerializer
.
UTF_8
);
redisTemplate
.
setHashKeySerializer
(
StringRedisSerializer
.
UTF_8
);
redisTemplate
.
afterPropertiesSet
();
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/config/RedisCacheConfig.java
deleted
100644 → 0
View file @
a70cc846
package
cn
.
datax
.
service
.
data
.
factory
.
config
;
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.RedisSerializationContext
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
java.lang.reflect.Method
;
import
java.time.Duration
;
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
,
RedisSerializer
<
Object
>
redisSerializer
)
{
return
new
RedisCacheManager
(
RedisCacheWriter
.
nonLockingRedisCacheWriter
(
redisConnectionFactory
),
this
.
redisCacheConfigurationWithTtl
(
30
,
redisSerializer
),
this
.
redisCacheConfigurationMap
(
redisSerializer
)
);
}
private
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
(
RedisSerializer
<
Object
>
redisSerializer
)
{
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
=
new
HashMap
<>();
redisCacheConfigurationMap
.
put
(
"data:factory:sources"
,
redisCacheConfigurationWithTtl
(
30
,
redisSerializer
));
redisCacheConfigurationMap
.
put
(
"data:factory:sets"
,
redisCacheConfigurationWithTtl
(
30
,
redisSerializer
));
return
redisCacheConfigurationMap
;
}
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
,
RedisSerializer
<
Object
>
redisSerializer
)
{
RedisCacheConfiguration
redisCacheConfiguration
=
RedisCacheConfiguration
.
defaultCacheConfig
();
redisCacheConfiguration
=
redisCacheConfiguration
.
serializeValuesWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
redisSerializer
)
).
entryTtl
(
Duration
.
ofMinutes
(
minutes
));
return
redisCacheConfiguration
;
}
}
\ No newline at end of file
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/controller/DataSetController.java
View file @
8d379f97
...
...
@@ -62,8 +62,8 @@ public class DataSetController extends BaseController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/{id}"
)
public
R
getDataSetById
(
@PathVariable
String
id
)
{
DataSet
Entity
dataSetEntity
=
dataSetService
.
g
etById
(
id
);
return
R
.
ok
().
setData
(
dataSet
Mapper
.
toVO
(
dataSetEntity
)
);
DataSet
Vo
dataSetVo
=
dataSetService
.
getDataS
etById
(
id
);
return
R
.
ok
().
setData
(
dataSet
Vo
);
}
/**
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/controller/DataSourceController.java
View file @
8d379f97
...
...
@@ -57,8 +57,8 @@ public class DataSourceController extends BaseController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/{id}"
)
public
R
getDataSourceById
(
@PathVariable
String
id
)
{
DataSource
Entity
dataSourceEntity
=
dataSourceService
.
get
ById
(
id
);
return
R
.
ok
().
setData
(
dataSource
Mapper
.
toVO
(
dataSourceEntity
)
);
DataSource
Vo
dataSourceVo
=
dataSourceService
.
getDataSource
ById
(
id
);
return
R
.
ok
().
setData
(
dataSource
Vo
);
}
/**
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/controller/InnerController.java
View file @
8d379f97
...
...
@@ -3,8 +3,7 @@ package cn.datax.service.data.factory.controller;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.R
;
import
cn.datax.common.security.annotation.DataInner
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.service.data.factory.mapstruct.DataSourceMapper
;
import
cn.datax.service.data.factory.api.vo.DataSourceVo
;
import
cn.datax.service.data.factory.service.DataSourceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -19,13 +18,10 @@ public class InnerController extends BaseController {
@Autowired
private
DataSourceService
dataSourceService
;
@Autowired
private
DataSourceMapper
dataSourceMapper
;
@DataInner
@GetMapping
(
"/dataSource/{id}"
)
public
R
getDataSourceById
(
@PathVariable
String
id
)
{
DataSource
Entity
dataSourceEntity
=
dataSourceService
.
get
ById
(
id
);
return
R
.
ok
().
setData
(
dataSource
Mapper
.
toVO
(
dataSourceEntity
)
);
DataSource
Vo
dataSourceVo
=
dataSourceService
.
getDataSource
ById
(
id
);
return
R
.
ok
().
setData
(
dataSource
Vo
);
}
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/DataSetService.java
View file @
8d379f97
...
...
@@ -3,6 +3,7 @@ package cn.datax.service.data.factory.service;
import
cn.datax.service.data.factory.api.entity.DataSetEntity
;
import
cn.datax.service.data.factory.api.dto.DataSetDto
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.service.data.factory.api.vo.DataSetVo
;
/**
* <p>
...
...
@@ -18,5 +19,7 @@ public interface DataSetService extends BaseService<DataSetEntity> {
void
updateDataSet
(
DataSetDto
dataSet
);
DataSetVo
getDataSetById
(
String
id
);
void
deleteDataSetById
(
String
id
);
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/DataSourceService.java
View file @
8d379f97
...
...
@@ -4,6 +4,7 @@ import cn.datax.common.database.DbQuery;
import
cn.datax.service.data.factory.api.dto.DataSourceDto
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.service.data.factory.api.vo.DataSourceVo
;
/**
* <p>
...
...
@@ -19,6 +20,8 @@ public interface DataSourceService extends BaseService<DataSourceEntity> {
void
updateDataSource
(
DataSourceDto
dataSource
);
DataSourceVo
getDataSourceById
(
String
id
);
void
deleteDataSourceById
(
String
id
);
DbQuery
checkConnection
(
DataSourceDto
dataSource
);
...
...
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/impl/DataSetServiceImpl.java
View file @
8d379f97
...
...
@@ -2,21 +2,16 @@ package cn.datax.service.data.factory.service.impl;
import
cn.datax.service.data.factory.api.dto.DataSetDto
;
import
cn.datax.service.data.factory.api.entity.DataSetEntity
;
import
cn.datax.service.data.factory.api.vo.DataSetVo
;
import
cn.datax.service.data.factory.service.DataSetService
;
import
cn.datax.service.data.factory.mapstruct.DataSetMapper
;
import
cn.datax.service.data.factory.dao.DataSetDao
;
import
cn.datax.common.base.BaseServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.Serializable
;
/**
* <p>
* 数据集信息表 服务实现类
...
...
@@ -25,7 +20,6 @@ import java.io.Serializable;
* @author yuwei
* @since 2020-03-20
*/
//@CacheConfig(cacheNames = "data:factory:sets")
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DataSetServiceImpl
extends
BaseServiceImpl
<
DataSetDao
,
DataSetEntity
>
implements
DataSetService
{
...
...
@@ -43,7 +37,6 @@ public class DataSetServiceImpl extends BaseServiceImpl<DataSetDao, DataSetEntit
dataSetDao
.
insert
(
dataSet
);
}
// @CachePut(key = "#p0.id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataSet
(
DataSetDto
dataSetDto
)
{
...
...
@@ -51,13 +44,12 @@ public class DataSetServiceImpl extends BaseServiceImpl<DataSetDao, DataSetEntit
dataSetDao
.
updateById
(
dataSet
);
}
// @Cacheable(key = "#id", unless = "#result == null")
@Override
public
DataSetEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
public
DataSetVo
getDataSetById
(
String
id
)
{
DataSetEntity
dataSetEntity
=
super
.
getById
(
id
);
return
dataSetMapper
.
toVO
(
dataSetEntity
);
}
// @CacheEvict(key = "#id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
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 @
8d379f97
...
...
@@ -6,15 +6,12 @@ import cn.datax.common.database.constants.DbQueryProperty;
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.entity.DataSourceEntity
;
import
cn.datax.service.data.factory.api.vo.DataSourceVo
;
import
cn.datax.service.data.factory.dao.DataSourceDao
;
import
cn.datax.service.data.factory.service.DataSourceService
;
import
cn.datax.service.data.factory.mapstruct.DataSourceMapper
;
import
cn.datax.common.base.BaseServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -29,7 +26,6 @@ import java.io.Serializable;
* @author yuwei
* @since 2020-03-14
*/
//@CacheConfig(cacheNames = "data:factory:sources")
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DataSourceServiceImpl
extends
BaseServiceImpl
<
DataSourceDao
,
DataSourceEntity
>
implements
DataSourceService
{
...
...
@@ -50,7 +46,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
dataSourceDao
.
insert
(
dataSource
);
}
// @CachePut(key = "#p0.id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataSource
(
DataSourceDto
dataSourceDto
)
{
...
...
@@ -58,13 +53,12 @@ public class DataSourceServiceImpl extends BaseServiceImpl<DataSourceDao, DataSo
dataSourceDao
.
updateById
(
dataSource
);
}
// @Cacheable(key = "#id", unless = "#result == null")
@Override
public
DataSourceEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
public
DataSourceVo
getDataSourceById
(
String
id
)
{
DataSourceEntity
dataSourceEntity
=
super
.
getById
(
id
);
return
dataSourceMapper
.
toVO
(
dataSourceEntity
);
}
// @CacheEvict(key = "#id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteDataSourceById
(
String
id
)
{
...
...
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/config/RedisCacheConfig.java
deleted
100644 → 0
View file @
a70cc846
package
cn
.
datax
.
service
.
data
.
market
.
config
;
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.RedisSerializationContext
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
java.lang.reflect.Method
;
import
java.time.Duration
;
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
,
RedisSerializer
<
Object
>
redisSerializer
)
{
return
new
RedisCacheManager
(
RedisCacheWriter
.
nonLockingRedisCacheWriter
(
redisConnectionFactory
),
this
.
redisCacheConfigurationWithTtl
(
30
,
redisSerializer
),
this
.
redisCacheConfigurationMap
(
redisSerializer
)
);
}
private
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
(
RedisSerializer
<
Object
>
redisSerializer
)
{
Map
<
String
,
RedisCacheConfiguration
>
redisCacheConfigurationMap
=
new
HashMap
<>();
redisCacheConfigurationMap
.
put
(
"data:market:apis"
,
redisCacheConfigurationWithTtl
(
30
,
redisSerializer
));
redisCacheConfigurationMap
.
put
(
"data:market:api:masks"
,
redisCacheConfigurationWithTtl
(
30
,
redisSerializer
));
return
redisCacheConfigurationMap
;
}
private
RedisCacheConfiguration
redisCacheConfigurationWithTtl
(
Integer
minutes
,
RedisSerializer
<
Object
>
redisSerializer
)
{
// ObjectMapper objectMapper = new ObjectMapper();
// objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// //使用JSR310提供的序列化类,里面包含了大量的JDK8时间序列化类
// objectMapper.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")));
// objectMapper.registerModule(javaTimeModule);
// //反序列化时候遇到不匹配的属性并不抛出异常
// objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// //序列化时候遇到空对象不抛出异常
// objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
// //反序列化的时候如果是无效子类型,不抛出异常
// objectMapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
// //不使用默认的dateTime进行序列化,
// objectMapper.configure(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false);
// //启用反序列化所需的类型信息,在属性中添加@class
// objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
// //配置null值的序列化器
// GenericJackson2JsonRedisSerializer.registerNullValueSerializer(objectMapper, null);
// GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer(objectMapper);
RedisCacheConfiguration
redisCacheConfiguration
=
RedisCacheConfiguration
.
defaultCacheConfig
();
redisCacheConfiguration
=
redisCacheConfiguration
.
serializeValuesWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
redisSerializer
)
).
entryTtl
(
Duration
.
ofMinutes
(
minutes
));
return
redisCacheConfiguration
;
}
}
\ No newline at end of file
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/ApiMaskController.java
View file @
8d379f97
...
...
@@ -53,8 +53,8 @@ public class ApiMaskController extends BaseController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/{id}"
)
public
R
getApiMaskById
(
@PathVariable
String
id
)
{
ApiMask
Entity
apiMaskEntity
=
apiMaskService
.
get
ById
(
id
);
return
R
.
ok
().
setData
(
apiMask
Mapper
.
toVO
(
apiMaskEntity
)
);
ApiMask
Vo
apiMaskVo
=
apiMaskService
.
getApiMask
ById
(
id
);
return
R
.
ok
().
setData
(
apiMask
Vo
);
}
/**
...
...
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/DataApiController.java
View file @
8d379f97
...
...
@@ -56,8 +56,8 @@ public class DataApiController extends BaseController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/{id}"
)
public
R
getDataApiById
(
@PathVariable
String
id
)
{
DataApi
Entity
dataApiEntity
=
dataApiService
.
get
ById
(
id
);
return
R
.
ok
().
setData
(
dataApi
Mapper
.
toVO
(
dataApiEntity
)
);
DataApi
Vo
dataApiVo
=
dataApiService
.
getDataApi
ById
(
id
);
return
R
.
ok
().
setData
(
dataApi
Vo
);
}
/**
...
...
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/InnerController.java
View file @
8d379f97
...
...
@@ -3,13 +3,10 @@ package cn.datax.service.data.market.controller;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.R
;
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.mapstruct.ApiMaskMapper
;
import
cn.datax.service.data.market.mapstruct.DataApiMapper
;
import
cn.datax.service.data.market.api.vo.ApiMaskVo
;
import
cn.datax.service.data.market.api.vo.DataApiVo
;
import
cn.datax.service.data.market.service.ApiMaskService
;
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.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -24,14 +21,8 @@ public class InnerController extends BaseController {
private
DataApiService
dataApiService
;
@Autowired
private
DataApiMapper
dataApiMapper
;
@Autowired
private
ApiMaskService
apiMaskService
;
@Autowired
private
ApiMaskMapper
apiMaskMapper
;
/**
* 通过ID查询信息
*
...
...
@@ -41,8 +32,8 @@ public class InnerController extends BaseController {
@DataInner
@GetMapping
(
"/dataApi/{id}"
)
public
R
getDataApiById
(
@PathVariable
String
id
)
{
DataApi
Entity
dataApiEntity
=
dataApiService
.
get
ById
(
id
);
return
R
.
ok
().
setData
(
dataApi
Mapper
.
toVO
(
dataApiEntity
)
);
DataApi
Vo
dataApiVo
=
dataApiService
.
getDataApi
ById
(
id
);
return
R
.
ok
().
setData
(
dataApi
Vo
);
}
/**
...
...
@@ -54,7 +45,7 @@ public class InnerController extends BaseController {
@DataInner
@GetMapping
(
"/apiMask/{apiId}"
)
public
R
getApiMaskByApiId
(
@PathVariable
String
apiId
)
{
ApiMask
Entity
apiMaskEntity
=
apiMaskService
.
getOne
(
new
QueryWrapper
<
ApiMaskEntity
>().
eq
(
"api_id"
,
apiId
)
);
return
R
.
ok
().
setData
(
apiMask
Mapper
.
toVO
(
apiMaskEntity
)
);
ApiMask
Vo
apiMaskVo
=
apiMaskService
.
getApiMaskByApiId
(
apiId
);
return
R
.
ok
().
setData
(
apiMask
Vo
);
}
}
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/service/ApiMaskService.java
View file @
8d379f97
...
...
@@ -3,6 +3,7 @@ package cn.datax.service.data.market.service;
import
cn.datax.common.base.BaseService
;
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.vo.ApiMaskVo
;
/**
* <p>
...
...
@@ -18,5 +19,9 @@ public interface ApiMaskService extends BaseService<ApiMaskEntity> {
void
updateApiMask
(
ApiMaskDto
dataApiMask
);
ApiMaskVo
getApiMaskById
(
String
id
);
ApiMaskVo
getApiMaskByApiId
(
String
apiId
);
void
deleteApiMaskById
(
String
id
);
}
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/service/DataApiService.java
View file @
8d379f97
...
...
@@ -4,6 +4,7 @@ import cn.datax.service.data.market.api.dto.SqlParseDto;
import
cn.datax.service.data.market.api.entity.DataApiEntity
;
import
cn.datax.service.data.market.api.dto.DataApiDto
;
import
cn.datax.common.base.BaseService
;
import
cn.datax.service.data.market.api.vo.DataApiVo
;
import
cn.datax.service.data.market.api.vo.SqlParseVo
;
/**
...
...
@@ -20,6 +21,8 @@ public interface DataApiService extends BaseService<DataApiEntity> {
void
updateDataApi
(
DataApiDto
dataApi
);
DataApiVo
getDataApiById
(
String
id
);
void
deleteDataApiById
(
String
id
);
SqlParseVo
sqlParse
(
SqlParseDto
sqlParseDto
);
...
...
datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/service/impl/ApiMaskServiceImpl.java
View file @
8d379f97
...
...
@@ -3,20 +3,16 @@ package cn.datax.service.data.market.service.impl;
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.api.vo.ApiMaskVo
;
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
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.Serializable
;
/**
* <p>
* 数据API脱敏信息表 服务实现类
...
...
@@ -25,7 +21,6 @@ import java.io.Serializable;
* @author yuwei
* @since 2020-04-14
*/
//@CacheConfig(cacheNames = "data:api:masks")
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
ApiMaskServiceImpl
extends
BaseServiceImpl
<
ApiMaskDao
,
ApiMaskEntity
>
implements
ApiMaskService
{
...
...
@@ -43,7 +38,6 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
apiMaskDao
.
insert
(
apiMask
);
}
// @CachePut(key = "#p0.id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateApiMask
(
ApiMaskDto
apiMaskDto
)
{
...
...
@@ -51,13 +45,18 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
apiMaskDao
.
updateById
(
apiMask
);
}
// @Cacheable(key = "#id")
@Override
public
ApiMaskEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
public
ApiMaskVo
getApiMaskById
(
String
id
)
{
ApiMaskEntity
apiMaskEntity
=
super
.
getById
(
id
);
return
apiMaskMapper
.
toVO
(
apiMaskEntity
);
}
@Override
public
ApiMaskVo
getApiMaskByApiId
(
String
apiId
)
{
ApiMaskEntity
apiMaskEntity
=
apiMaskDao
.
selectOne
(
new
QueryWrapper
<
ApiMaskEntity
>().
eq
(
"api_id"
,
apiId
));
return
apiMaskMapper
.
toVO
(
apiMaskEntity
);
}
// @CacheEvict(key = "#id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
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 @
8d379f97
...
...
@@ -5,6 +5,7 @@ import cn.datax.common.utils.ThrowableUtil;
import
cn.datax.service.data.market.api.dto.*
;
import
cn.datax.service.data.market.api.entity.DataApiEntity
;
import
cn.datax.service.data.market.api.enums.ConfigType
;
import
cn.datax.service.data.market.api.vo.DataApiVo
;
import
cn.datax.service.data.market.api.vo.SqlParseVo
;
import
cn.datax.service.data.market.service.DataApiService
;
import
cn.datax.service.data.market.mapstruct.DataApiMapper
;
...
...
@@ -27,15 +28,10 @@ import net.sf.jsqlparser.util.SelectUtils;
import
net.sf.jsqlparser.util.deparser.ExpressionDeParser
;
import
net.sf.jsqlparser.util.deparser.SelectDeParser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -48,7 +44,6 @@ import java.util.stream.Collectors;
* @author yuwei
* @since 2020-03-31
*/
//@CacheConfig(cacheNames = "data:market:apis")
@Slf4j
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
...
...
@@ -67,7 +62,6 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
dataApiDao
.
insert
(
dataApi
);
}
// @CachePut(key = "#p0.id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataApi
(
DataApiDto
dataApiDto
)
{
...
...
@@ -89,13 +83,12 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
return
dataApi
;
}
// @Cacheable(key = "#id", unless = "#result == null")
@Override
public
DataApiEntity
getById
(
Serializable
id
)
{
return
super
.
getById
(
id
);
public
DataApiVo
getDataApiById
(
String
id
)
{
DataApiEntity
dataApiEntity
=
super
.
getById
(
id
);
return
dataApiMapper
.
toVO
(
dataApiEntity
);
}
// @CacheEvict(key = "#id")
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteDataApiById
(
String
id
)
{
...
...
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