mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 08:57:17 +08:00
refactor: 优化行为验证码缓存自动配置
This commit is contained in:
@@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.redisson.client.RedisClient;
|
import org.redisson.client.RedisClient;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoConfiguration;
|
import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoConfiguration;
|
||||||
@@ -49,11 +50,8 @@ abstract class BehaviorCaptchaCacheConfiguration {
|
|||||||
@ConditionalOnClass(RedisClient.class)
|
@ConditionalOnClass(RedisClient.class)
|
||||||
@AutoConfigureBefore(RedissonAutoConfiguration.class)
|
@AutoConfigureBefore(RedissonAutoConfiguration.class)
|
||||||
@ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "redis")
|
@ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "redis")
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
static class Redis {
|
static class Redis {
|
||||||
|
static {
|
||||||
@PostConstruct
|
|
||||||
public void postConstruct() {
|
|
||||||
CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), new BehaviorCaptchaCacheServiceImpl());
|
CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), new BehaviorCaptchaCacheServiceImpl());
|
||||||
log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Redis' completed initialization.");
|
log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Redis' completed initialization.");
|
||||||
}
|
}
|
||||||
@@ -63,10 +61,10 @@ abstract class BehaviorCaptchaCacheConfiguration {
|
|||||||
* 自定义缓存实现类-自定义
|
* 自定义缓存实现类-自定义
|
||||||
*/
|
*/
|
||||||
@ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "custom")
|
@ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "custom")
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
static class Custom {
|
static class Custom {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
public CaptchaCacheService captchaCacheService(BehaviorCaptchaProperties properties) {
|
public CaptchaCacheService captchaCacheService(BehaviorCaptchaProperties properties) {
|
||||||
return ReflectUtil.newInstance(properties.getCacheImpl());
|
return ReflectUtil.newInstance(properties.getCacheImpl());
|
||||||
}
|
}
|
||||||
|
@@ -180,7 +180,7 @@
|
|||||||
<version>${x-file-storage.version}</version>
|
<version>${x-file-storage.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Amazon Simple Storage Service(亚马逊简单存储服务,通用存储协议 S3,兼容主流云厂商对象存储) -->
|
<!-- Amazon S3(Amazon Simple Storage Service,亚马逊简单存储服务,通用存储协议 S3,兼容主流云厂商对象存储) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
|
Reference in New Issue
Block a user