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 | 43 | <!-- Bpm 工作流相关 --> |
| 44 | 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 | 47 | <jsoup.version>1.15.4</jsoup.version> |
| 48 | 48 | <lombok.version>1.18.26</lombok.version> |
| 49 | 49 | <mapstruct.version>1.5.5.Final</mapstruct.version> |
| ... | ... | @@ -67,7 +67,7 @@ |
| 67 | 67 | <minio.version>8.5.2</minio.version> |
| 68 | 68 | <aliyun-java-sdk-core.version>4.6.3</aliyun-java-sdk-core.version> |
| 69 | 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 | 71 | <justauth.version>1.4.0</justauth.version> |
| 72 | 72 | <jimureport.version>1.5.6</jimureport.version> |
| 73 | 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 | 3 | import cn.hutool.core.util.ClassUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.captcha.core.enums.CaptchaRedisKeyConstants; |
| 5 | 5 | import cn.iocoder.yudao.framework.captcha.core.service.RedisCaptchaServiceImpl; |
| 6 | +import com.xingyuv.captcha.properties.AjCaptchaProperties; | |
| 6 | 7 | import com.xingyuv.captcha.service.CaptchaCacheService; |
| 8 | +import com.xingyuv.captcha.service.impl.CaptchaServiceFactory; | |
| 7 | 9 | import org.springframework.boot.autoconfigure.AutoConfiguration; |
| 8 | 10 | import org.springframework.context.annotation.Bean; |
| 9 | 11 | import org.springframework.data.redis.core.StringRedisTemplate; |
| 10 | 12 | |
| 13 | +import javax.annotation.Resource; | |
| 14 | + | |
| 11 | 15 | @AutoConfiguration |
| 12 | 16 | public class YudaoCaptchaConfiguration { |
| 13 | 17 | |
| ... | ... | @@ -17,9 +21,17 @@ public class YudaoCaptchaConfiguration { |
| 17 | 21 | ClassUtil.loadClass(CaptchaRedisKeyConstants.class.getName()); |
| 18 | 22 | } |
| 19 | 23 | |
| 24 | + @Resource | |
| 25 | + private StringRedisTemplate stringRedisTemplate; | |
| 26 | + | |
| 20 | 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 | 25 | return "redis"; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | + public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) { | |
| 29 | + this.stringRedisTemplate = stringRedisTemplate; | |
| 30 | + } | |
| 31 | + | |
| 28 | 32 | @Override |
| 29 | 33 | public void set(String key, String value, long expiresInSeconds) { |
| 30 | 34 | stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS); | ... | ... |