mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-10-31 10:57:15 +08:00 
			
		
		
		
	!2 修复行为验证码 Redis、自定义缓存无法加载到缓存工厂问题
Merge pull request !2 from Yoofff/dev
This commit is contained in:
		| @@ -60,7 +60,7 @@ public class BehaviorCaptchaAutoConfiguration { | ||||
|      * 自定义缓存实现配置 | ||||
|      */ | ||||
|     @Configuration | ||||
|     @Import({BehaviorCaptchaCacheConfiguration.Redis.class, BehaviorCaptchaCacheConfiguration.Local.class, BehaviorCaptchaCacheConfiguration.Custom.class}) | ||||
|     @Import({BehaviorCaptchaCacheConfiguration.Redis.class,BehaviorCaptchaCacheConfiguration.Custom.class}) | ||||
|     protected static class BehaviorCaptchaCacheAutoConfiguration { | ||||
|     } | ||||
|  | ||||
| @@ -79,7 +79,7 @@ public class BehaviorCaptchaAutoConfiguration { | ||||
|         config.put(Const.ORIGINAL_PATH_JIGSAW, StrUtil.emptyIfNull(properties.getJigsawBaseMapPath())); | ||||
|         config.put(Const.ORIGINAL_PATH_PIC_CLICK, StrUtil.emptyIfNull(properties.getPicClickBaseMapPath())); | ||||
|         config.put(Const.CAPTCHA_SLIP_OFFSET, properties.getSlipOffset()); | ||||
|         config.put(Const.CAPTCHA_AES_STATUS, String.valueOf(properties.getEnableAES())); | ||||
|         config.put(Const.CAPTCHA_AES_STATUS, String.valueOf(properties.getEnableAes())); | ||||
|         config.put(Const.CAPTCHA_WATER_FONT, properties.getWaterFont()); | ||||
|         config.put(Const.CAPTCHA_CACAHE_MAX_NUMBER, properties.getCacheNumber()); | ||||
|         config.put(Const.CAPTCHA_TIMING_CLEAR_SECOND, properties.getTimingClear()); | ||||
|   | ||||
| @@ -18,7 +18,8 @@ package top.charles7c.continew.starter.captcha.behavior.autoconfigure; | ||||
|  | ||||
| import cn.hutool.core.util.ReflectUtil; | ||||
| import com.anji.captcha.service.CaptchaCacheService; | ||||
| import com.anji.captcha.service.impl.CaptchaCacheServiceMemImpl; | ||||
| import com.anji.captcha.service.impl.CaptchaServiceFactory; | ||||
| import jakarta.annotation.PostConstruct; | ||||
| import lombok.AccessLevel; | ||||
| import lombok.NoArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| @@ -27,8 +28,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoConfiguration; | ||||
| import top.charles7c.continew.starter.captcha.behavior.enums.StorageType; | ||||
| import top.charles7c.continew.starter.captcha.behavior.impl.BehaviorCaptchaCacheServiceImpl; | ||||
|  | ||||
| /** | ||||
| @@ -48,31 +49,14 @@ abstract class BehaviorCaptchaCacheConfiguration { | ||||
|     @ConditionalOnMissingBean(CaptchaCacheService.class) | ||||
|     @AutoConfigureBefore(RedissonAutoConfiguration.class) | ||||
|     @ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "redis") | ||||
|     @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||||
|     static class Redis { | ||||
|         static { | ||||
|  | ||||
|         @PostConstruct | ||||
|         public void captchaCacheService() { | ||||
|             CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), new BehaviorCaptchaCacheServiceImpl()); | ||||
|             log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Redis' completed initialization."); | ||||
|         } | ||||
|  | ||||
|         @Bean | ||||
|         public CaptchaCacheService captchaCacheService() { | ||||
|             return new BehaviorCaptchaCacheServiceImpl(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 自定义缓存实现类-内存 | ||||
|      */ | ||||
|     @ConditionalOnMissingBean(CaptchaCacheService.class) | ||||
|     @ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "local") | ||||
|     static class Local { | ||||
|         static { | ||||
|             log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Local' completed initialization."); | ||||
|         } | ||||
|  | ||||
|         @Bean | ||||
|         public CaptchaCacheService captchaCacheService() { | ||||
|             return new CaptchaCacheServiceMemImpl(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -80,14 +64,13 @@ abstract class BehaviorCaptchaCacheConfiguration { | ||||
|      */ | ||||
|     @ConditionalOnMissingBean(CaptchaCacheService.class) | ||||
|     @ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "custom") | ||||
|     @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||||
|     static class Custom { | ||||
|         static { | ||||
|  | ||||
|         @PostConstruct | ||||
|         public void captchaCacheService(BehaviorCaptchaProperties properties) { | ||||
|             CaptchaServiceFactory.cacheService.put(StorageType.CUSTOM.name().toLowerCase(), ReflectUtil.newInstance(properties.getCacheImpl())); | ||||
|             log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Custom' completed initialization."); | ||||
|         } | ||||
|  | ||||
|         @Bean | ||||
|         public CaptchaCacheService captchaCacheService(BehaviorCaptchaProperties properties) { | ||||
|             return ReflectUtil.newInstance(properties.getCacheImpl()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -42,7 +42,7 @@ public class BehaviorCaptchaProperties { | ||||
|     /** | ||||
|      * 是否开启 AES 坐标加密(默认:true) | ||||
|      */ | ||||
|     private Boolean enableAES = true; | ||||
|     private Boolean enableAes = true; | ||||
|  | ||||
|     /** | ||||
|      * 验证码类型(默认:滑动验证码) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Gitee
						Gitee