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