Skip to content

Commit

Permalink
Merge pull request #223 from shiyindaxiaojie/feature
Browse files Browse the repository at this point in the history
update
  • Loading branch information
shiyindaxiaojie authored Nov 6, 2024
2 parents f095407 + b27b19f commit effc3a6
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author <a href="mailto:[email protected]">gyl</a>
* @since 2.4.13
*/
@Plugin(name = "MaskingStringLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true)
@Plugin(name = "DataMaskerStringLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true)
public class DataMaskerStringLayout extends AbstractStringLayout {

private static final String KEY = "Converter";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static DataMasker build(String spi, String strategy) {
*/
public static DataMasker build(DataMaskerConfig config) {
return ExtensionLoader.getExtensionLoader(DataMaskerBuilder.class)
.getDefaultExtension()
.getExtension(config.getType())
.config(config)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
chars-scan=org.ylzl.eden.data.masker.integration.charsscan.CharsScanDataMasker
address=org.ylzl.eden.data.masker.spi.AddressDataMasker
bank-card=org.ylzl.eden.data.masker.spi.BankCardDataMasker
car-license=org.ylzl.eden.data.masker.spi.CarLicenseDataMasker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.springframework.context.annotation.Role;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.ylzl.eden.idempotent.integration.ttl.RedisTimeToLiveIdempotentStrategy;
import org.ylzl.eden.idempotent.spring.boot.env.TimeToLiveIdempotentConvertor;
import org.ylzl.eden.idempotent.spring.boot.env.TimeToLiveIdempotentProperties;
import org.ylzl.eden.idempotent.spring.boot.env.IdempotentConvertor;
import org.ylzl.eden.idempotent.spring.boot.env.IdempotentProperties;
import org.ylzl.eden.idempotent.strategy.TimeToLiveIdempotentStrategy;

/**
Expand All @@ -48,15 +48,16 @@
@Configuration(proxyBeanMethods = false)
public class RedisTimeToLiveIdempotentAutoConfiguration {

public static final String ENABLED = TimeToLiveIdempotentProperties.PREFIX + ".redis.enabled";
public static final String ENABLED = IdempotentProperties.TimeToLive.PREFIX + ".redis.enabled";

private static final String AUTOWIRED_REDIS_TTL_IDEMPOTENT_STRATEGY = "Autowired RedisTimeToLiveIdempotentStrategy";

private final TimeToLiveIdempotentProperties properties;
private final IdempotentProperties properties;

@Bean
public TimeToLiveIdempotentStrategy ttlIdempotentStrategy(StringRedisTemplate redisTemplate) {
log.debug(AUTOWIRED_REDIS_TTL_IDEMPOTENT_STRATEGY);
return new RedisTimeToLiveIdempotentStrategy(redisTemplate, TimeToLiveIdempotentConvertor.INSTANCE.toConfig(properties));
return new RedisTimeToLiveIdempotentStrategy(redisTemplate,
IdempotentConvertor.INSTANCE.toTimeToLiveConfig(properties.getTtl()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.springframework.context.annotation.Role;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.ylzl.eden.idempotent.integration.token.RedisTokenIdempotentStrategy;
import org.ylzl.eden.idempotent.spring.boot.env.TokenIdempotentConvertor;
import org.ylzl.eden.idempotent.spring.boot.env.TokenIdempotentProperties;
import org.ylzl.eden.idempotent.spring.boot.env.IdempotentConvertor;
import org.ylzl.eden.idempotent.spring.boot.env.IdempotentProperties;
import org.ylzl.eden.idempotent.strategy.TokenIdempotentStrategy;

/**
Expand All @@ -46,15 +46,16 @@
@Configuration(proxyBeanMethods = false)
public class RedisTokenIdempotentAutoConfiguration {

public static final String ENABLED = TokenIdempotentProperties.PREFIX + ".redis.enabled";
public static final String ENABLED = IdempotentProperties.Token.PREFIX + ".redis.enabled";

private static final String AUTOWIRED_REDIS_TOKEN_IDEMPOTENT_STRATEGY = "Autowired RedisTokenIdempotentStrategy";

private final TokenIdempotentProperties properties;
private final IdempotentProperties properties;

@Bean
public TokenIdempotentStrategy tokenIdempotentStrategy(StringRedisTemplate redisTemplate) {
log.debug(AUTOWIRED_REDIS_TOKEN_IDEMPOTENT_STRATEGY);
return new RedisTokenIdempotentStrategy(redisTemplate, TokenIdempotentConvertor.INSTANCE.toConfig(properties));
return new RedisTokenIdempotentStrategy(redisTemplate,
IdempotentConvertor.INSTANCE.toTokenConfig(properties.getToken()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Role;
import org.ylzl.eden.idempotent.spring.boot.env.TimeToLiveIdempotentProperties;
import org.ylzl.eden.idempotent.spring.boot.env.IdempotentProperties;

/**
* 幂等请求自动装配
*
* @author <a href="mailto:[email protected]">gyl</a>
* @since 2.4.13
*/
@ConditionalOnProperty(prefix = TimeToLiveIdempotentProperties.PREFIX)
@EnableConfigurationProperties(TimeToLiveIdempotentProperties.class)
@ConditionalOnProperty(prefix = IdempotentProperties.TimeToLive.PREFIX)
@EnableConfigurationProperties(IdempotentProperties.class)
@RequiredArgsConstructor
@Import(TimeToLiveIdempotentAspectRegistrar.class)
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
import org.ylzl.eden.commons.lang.StringUtils;
import org.ylzl.eden.idempotent.spring.boot.env.TokenIdempotentProperties;
import org.ylzl.eden.idempotent.spring.boot.env.IdempotentProperties;
import org.ylzl.eden.idempotent.strategy.TokenIdempotentStrategy;
import org.ylzl.eden.idempotent.web.controller.TokenIdempotentController;
import org.ylzl.eden.idempotent.web.interceptor.TokenIdempotentInterceptor;
Expand All @@ -36,8 +36,8 @@
* @author <a href="mailto:[email protected]">gyl</a>
* @since 2.4.13
*/
@ConditionalOnProperty(prefix = TokenIdempotentProperties.PREFIX)
@EnableConfigurationProperties(TokenIdempotentProperties.class)
@ConditionalOnProperty(prefix = IdempotentProperties.Token.PREFIX)
@EnableConfigurationProperties(IdempotentProperties.class)
@RequiredArgsConstructor
@Slf4j
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
Expand All @@ -48,7 +48,7 @@ public class TokenIdempotentAutoConfiguration {

private static final String AUTOWIRED_IDEMPOTENT_TOKEN_INTERCEPTOR = "Autowired TokenIdempotentInterceptor";

private final TokenIdempotentProperties properties;
private final IdempotentProperties properties;

@Bean
public TokenIdempotentController idempotentTokenController(TokenIdempotentStrategy strategy) {
Expand All @@ -60,8 +60,8 @@ public TokenIdempotentController idempotentTokenController(TokenIdempotentStrate
public TokenIdempotentInterceptor idempotentTokenInterceptor(TokenIdempotentStrategy strategy) {
log.debug(AUTOWIRED_IDEMPOTENT_TOKEN_INTERCEPTOR);
TokenIdempotentInterceptor interceptor = new TokenIdempotentInterceptor(strategy);
if (StringUtils.isNotBlank(properties.getTokenName())) {
interceptor.setTokenName(properties.getTokenName());
if (StringUtils.isNotBlank(properties.getToken().getTokenName())) {
interceptor.setTokenName(properties.getToken().getTokenName());
}
return interceptor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;
import org.ylzl.eden.idempotent.config.TimeToLiveIdempotentConfig;
import org.ylzl.eden.idempotent.config.TokenIdempotentConfig;

/**
* 幂等配置转换器
Expand All @@ -30,9 +31,11 @@
*/
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface TimeToLiveIdempotentConvertor {
public interface IdempotentConvertor {

TimeToLiveIdempotentConvertor INSTANCE = Mappers.getMapper(TimeToLiveIdempotentConvertor.class);
IdempotentConvertor INSTANCE = Mappers.getMapper(IdempotentConvertor.class);

TimeToLiveIdempotentConfig toConfig(TimeToLiveIdempotentProperties properties);
TokenIdempotentConfig toTokenConfig(IdempotentProperties.Token properties);

TimeToLiveIdempotentConfig toTimeToLiveConfig(IdempotentProperties.TimeToLive properties);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,36 @@
*/
@Getter
@Setter
@ConfigurationProperties(prefix = TokenIdempotentProperties.PREFIX)
public class TokenIdempotentProperties {
@ConfigurationProperties(prefix = IdempotentProperties.PREFIX)
public class IdempotentProperties {

public static final String PREFIX = "idempotent.token";
public static final String PREFIX = "idempotent";

private String prefix = "idempotent:token";
private final Token token = new Token();

private long ttl = 10L;
private final TimeToLive ttl = new TimeToLive();

private TimeUnit timeUnit = TimeUnit.SECONDS;
@Getter
@Setter
public static class Token {

private String tokenName = "idempotent";
public static final String PREFIX = "idempotent.token";

private String prefix = "idempotent:token";

private long ttl = 10L;

private TimeUnit timeUnit = TimeUnit.SECONDS;

private String tokenName = "idempotent";
}

@Getter
@Setter
public static class TimeToLive {

public static final String PREFIX = "idempotent.ttl";

private String prefix = "idempotent:ttl";
}
}

This file was deleted.

This file was deleted.

0 comments on commit effc3a6

Please sign in to comment.