Commit b892a6d2bd21fbd54863880b557922e445202ab7
1 parent
25df1e2e
feat: captcha-plus 1.0.4
Showing
3 changed files
with
20 additions
and
4 deletions
yudao-dependencies/pom.xml
| @@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
| 43 | <!-- Bpm 工作流相关 --> | 43 | <!-- Bpm 工作流相关 --> |
| 44 | <flowable.version>6.8.0</flowable.version> | 44 | <flowable.version>6.8.0</flowable.version> |
| 45 | <!-- 工具类相关 --> | 45 | <!-- 工具类相关 --> |
| 46 | - <captcha-plus.version>1.0.2</captcha-plus.version> | 46 | + <captcha-plus.version>1.0.4</captcha-plus.version> |
| 47 | <jsoup.version>1.15.4</jsoup.version> | 47 | <jsoup.version>1.15.4</jsoup.version> |
| 48 | <lombok.version>1.18.26</lombok.version> | 48 | <lombok.version>1.18.26</lombok.version> |
| 49 | <mapstruct.version>1.5.5.Final</mapstruct.version> | 49 | <mapstruct.version>1.5.5.Final</mapstruct.version> |
| @@ -67,7 +67,7 @@ | @@ -67,7 +67,7 @@ | ||
| 67 | <minio.version>8.5.2</minio.version> | 67 | <minio.version>8.5.2</minio.version> |
| 68 | <aliyun-java-sdk-core.version>4.6.3</aliyun-java-sdk-core.version> | 68 | <aliyun-java-sdk-core.version>4.6.3</aliyun-java-sdk-core.version> |
| 69 | <aliyun-java-sdk-dysmsapi.version>2.2.1</aliyun-java-sdk-dysmsapi.version> | 69 | <aliyun-java-sdk-dysmsapi.version>2.2.1</aliyun-java-sdk-dysmsapi.version> |
| 70 | - <tencentcloud-sdk-java.version>3.1.715</tencentcloud-sdk-java.version> | 70 | + <tencentcloud-sdk-java.version>3.1.758</tencentcloud-sdk-java.version> |
| 71 | <justauth.version>1.4.0</justauth.version> | 71 | <justauth.version>1.4.0</justauth.version> |
| 72 | <jimureport.version>1.5.6</jimureport.version> | 72 | <jimureport.version>1.5.6</jimureport.version> |
| 73 | <xercesImpl.version>2.12.2</xercesImpl.version> | 73 | <xercesImpl.version>2.12.2</xercesImpl.version> |
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java
| @@ -3,11 +3,15 @@ package cn.iocoder.yudao.framework.captcha.config; | @@ -3,11 +3,15 @@ package cn.iocoder.yudao.framework.captcha.config; | ||
| 3 | import cn.hutool.core.util.ClassUtil; | 3 | import cn.hutool.core.util.ClassUtil; |
| 4 | import cn.iocoder.yudao.framework.captcha.core.enums.CaptchaRedisKeyConstants; | 4 | import cn.iocoder.yudao.framework.captcha.core.enums.CaptchaRedisKeyConstants; |
| 5 | import cn.iocoder.yudao.framework.captcha.core.service.RedisCaptchaServiceImpl; | 5 | import cn.iocoder.yudao.framework.captcha.core.service.RedisCaptchaServiceImpl; |
| 6 | +import com.xingyuv.captcha.properties.AjCaptchaProperties; | ||
| 6 | import com.xingyuv.captcha.service.CaptchaCacheService; | 7 | import com.xingyuv.captcha.service.CaptchaCacheService; |
| 8 | +import com.xingyuv.captcha.service.impl.CaptchaServiceFactory; | ||
| 7 | import org.springframework.boot.autoconfigure.AutoConfiguration; | 9 | import org.springframework.boot.autoconfigure.AutoConfiguration; |
| 8 | import org.springframework.context.annotation.Bean; | 10 | import org.springframework.context.annotation.Bean; |
| 9 | import org.springframework.data.redis.core.StringRedisTemplate; | 11 | import org.springframework.data.redis.core.StringRedisTemplate; |
| 10 | 12 | ||
| 13 | +import javax.annotation.Resource; | ||
| 14 | + | ||
| 11 | @AutoConfiguration | 15 | @AutoConfiguration |
| 12 | public class YudaoCaptchaConfiguration { | 16 | public class YudaoCaptchaConfiguration { |
| 13 | 17 | ||
| @@ -17,9 +21,17 @@ public class YudaoCaptchaConfiguration { | @@ -17,9 +21,17 @@ public class YudaoCaptchaConfiguration { | ||
| 17 | ClassUtil.loadClass(CaptchaRedisKeyConstants.class.getName()); | 21 | ClassUtil.loadClass(CaptchaRedisKeyConstants.class.getName()); |
| 18 | } | 22 | } |
| 19 | 23 | ||
| 24 | + @Resource | ||
| 25 | + private StringRedisTemplate stringRedisTemplate; | ||
| 26 | + | ||
| 20 | @Bean | 27 | @Bean |
| 21 | - public CaptchaCacheService captchaCacheService(StringRedisTemplate stringRedisTemplate) { | ||
| 22 | - return new RedisCaptchaServiceImpl(stringRedisTemplate); | 28 | + public CaptchaCacheService captchaCacheService(AjCaptchaProperties config) { |
| 29 | + //缓存类型redis/local/.... | ||
| 30 | + CaptchaCacheService ret = CaptchaServiceFactory.getCache(config.getCacheType().name()); | ||
| 31 | + if(ret instanceof RedisCaptchaServiceImpl){ | ||
| 32 | + ((RedisCaptchaServiceImpl)ret).setStringRedisTemplate(stringRedisTemplate); | ||
| 33 | + } | ||
| 34 | + return ret; | ||
| 23 | } | 35 | } |
| 24 | 36 | ||
| 25 | } | 37 | } |
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/service/RedisCaptchaServiceImpl.java
| @@ -25,6 +25,10 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService { | @@ -25,6 +25,10 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService { | ||
| 25 | return "redis"; | 25 | return "redis"; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | + public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) { | ||
| 29 | + this.stringRedisTemplate = stringRedisTemplate; | ||
| 30 | + } | ||
| 31 | + | ||
| 28 | @Override | 32 | @Override |
| 29 | public void set(String key, String value, long expiresInSeconds) { | 33 | public void set(String key, String value, long expiresInSeconds) { |
| 30 | stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS); | 34 | stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS); |