Commit d7656535a2eab25ad306007e7a3ae3908f6e731f
1 parent
4cebe4af
reactor:使用 aj-captcha 官方 1.4.0
Showing
9 changed files
with
29 additions
and
25 deletions
yudao-dependencies/pom.xml
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | <!-- Bpm 工作流相关 --> |
| 49 | 49 | <flowable.version>7.0.1</flowable.version> |
| 50 | 50 | <!-- 工具类相关 --> |
| 51 | - <captcha-plus.version>2.0.3</captcha-plus.version> | |
| 51 | + <anji-plus-captcha.version>1.4.0</anji-plus-captcha.version> | |
| 52 | 52 | <jsoup.version>1.18.3</jsoup.version> |
| 53 | 53 | <lombok.version>1.18.36</lombok.version> |
| 54 | 54 | <mapstruct.version>1.6.3</mapstruct.version> |
| ... | ... | @@ -535,9 +535,9 @@ |
| 535 | 535 | </dependency> |
| 536 | 536 | |
| 537 | 537 | <dependency> |
| 538 | - <groupId>com.xingyuv</groupId> | |
| 539 | - <artifactId>spring-boot-starter-captcha-plus</artifactId> | |
| 540 | - <version>${captcha-plus.version}</version> | |
| 538 | + <groupId>com.anji-plus</groupId> | |
| 539 | + <artifactId>captcha-spring-boot-starter</artifactId> <!-- 验证码,一般用于登录使用 --> | |
| 540 | + <version>${anji-plus-captcha.version}</version> | |
| 541 | 541 | </dependency> |
| 542 | 542 | |
| 543 | 543 | <dependency> | ... | ... |
yudao-module-system/yudao-module-system-biz/pom.xml
| ... | ... | @@ -115,8 +115,8 @@ |
| 115 | 115 | </dependency> |
| 116 | 116 | |
| 117 | 117 | <dependency> |
| 118 | - <groupId>com.xingyuv</groupId> | |
| 119 | - <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 --> | |
| 118 | + <groupId>com.anji-plus</groupId> | |
| 119 | + <artifactId>captcha-spring-boot-starter</artifactId> <!-- 验证码,一般用于登录使用 --> | |
| 120 | 120 | </dependency> |
| 121 | 121 | |
| 122 | 122 | <dependency> | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/captcha/CaptchaController.java
| ... | ... | @@ -2,20 +2,19 @@ package cn.iocoder.yudao.module.system.controller.admin.captcha; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 5 | -import com.xingyuv.captcha.model.common.ResponseModel; | |
| 6 | -import com.xingyuv.captcha.model.vo.CaptchaVO; | |
| 7 | -import com.xingyuv.captcha.service.CaptchaService; | |
| 5 | +import com.anji.captcha.model.common.ResponseModel; | |
| 6 | +import com.anji.captcha.model.vo.CaptchaVO; | |
| 7 | +import com.anji.captcha.service.CaptchaService; | |
| 8 | 8 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | 9 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 10 | +import jakarta.annotation.Resource; | |
| 11 | +import jakarta.annotation.security.PermitAll; | |
| 12 | +import jakarta.servlet.http.HttpServletRequest; | |
| 10 | 13 | import org.springframework.web.bind.annotation.PostMapping; |
| 11 | 14 | import org.springframework.web.bind.annotation.RequestBody; |
| 12 | 15 | import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | 16 | import org.springframework.web.bind.annotation.RestController; |
| 14 | 17 | |
| 15 | -import jakarta.annotation.Resource; | |
| 16 | -import jakarta.annotation.security.PermitAll; | |
| 17 | -import jakarta.servlet.http.HttpServletRequest; | |
| 18 | - | |
| 19 | 18 | @Tag(name = "管理后台 - 验证码") |
| 20 | 19 | @RestController("adminCaptchaController") |
| 21 | 20 | @RequestMapping("/system/captcha") | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/config/YudaoCaptchaConfiguration.java
| 1 | 1 | package cn.iocoder.yudao.module.system.framework.captcha.config; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl; |
| 4 | -import com.xingyuv.captcha.properties.AjCaptchaProperties; | |
| 5 | -import com.xingyuv.captcha.service.CaptchaCacheService; | |
| 6 | -import com.xingyuv.captcha.service.impl.CaptchaServiceFactory; | |
| 4 | +import com.anji.captcha.config.AjCaptchaAutoConfiguration; | |
| 5 | +import com.anji.captcha.properties.AjCaptchaProperties; | |
| 6 | +import com.anji.captcha.service.CaptchaCacheService; | |
| 7 | +import com.anji.captcha.service.impl.CaptchaServiceFactory; | |
| 8 | +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | |
| 7 | 9 | import org.springframework.context.annotation.Bean; |
| 8 | 10 | import org.springframework.context.annotation.Configuration; |
| 11 | +import org.springframework.context.annotation.Primary; | |
| 9 | 12 | import org.springframework.data.redis.core.StringRedisTemplate; |
| 10 | 13 | |
| 11 | 14 | /** |
| ... | ... | @@ -14,9 +17,11 @@ import org.springframework.data.redis.core.StringRedisTemplate; |
| 14 | 17 | * @author 芋道源码 |
| 15 | 18 | */ |
| 16 | 19 | @Configuration(proxyBeanMethods = false) |
| 20 | +@ImportAutoConfiguration(AjCaptchaAutoConfiguration.class) // 目的:解决 aj-captcha 针对 SpringBoot 3.X 自动配置不生效的问题 | |
| 17 | 21 | public class YudaoCaptchaConfiguration { |
| 18 | 22 | |
| 19 | - @Bean | |
| 23 | + @Bean(name = "AjCaptchaCacheService") | |
| 24 | + @Primary | |
| 20 | 25 | public CaptchaCacheService captchaCacheService(AjCaptchaProperties config, |
| 21 | 26 | StringRedisTemplate stringRedisTemplate) { |
| 22 | 27 | CaptchaCacheService captchaCacheService = CaptchaServiceFactory.getCache(config.getCacheType().name()); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/RedisCaptchaServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.framework.captcha.core; |
| 2 | 2 | |
| 3 | -import com.xingyuv.captcha.service.CaptchaCacheService; | |
| 3 | +import com.anji.captcha.service.CaptchaCacheService; | |
| 4 | 4 | import lombok.Setter; |
| 5 | 5 | import org.springframework.data.redis.core.StringRedisTemplate; |
| 6 | 6 | |
| ... | ... | @@ -28,7 +28,7 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService { |
| 28 | 28 | |
| 29 | 29 | @Override |
| 30 | 30 | public boolean exists(String key) { |
| 31 | - return Boolean.TRUE.equals(stringRedisTemplate.hasKey(key)); | |
| 31 | + return stringRedisTemplate.hasKey(key); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | @Override | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
| ... | ... | @@ -24,10 +24,10 @@ import cn.iocoder.yudao.module.system.service.member.MemberService; |
| 24 | 24 | import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; |
| 25 | 25 | import cn.iocoder.yudao.module.system.service.social.SocialUserService; |
| 26 | 26 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 27 | +import com.anji.captcha.model.common.ResponseModel; | |
| 28 | +import com.anji.captcha.model.vo.CaptchaVO; | |
| 29 | +import com.anji.captcha.service.CaptchaService; | |
| 27 | 30 | import com.google.common.annotations.VisibleForTesting; |
| 28 | -import com.xingyuv.captcha.model.common.ResponseModel; | |
| 29 | -import com.xingyuv.captcha.model.vo.CaptchaVO; | |
| 30 | -import com.xingyuv.captcha.service.CaptchaService; | |
| 31 | 31 | import jakarta.annotation.Resource; |
| 32 | 32 | import jakarta.validation.Validator; |
| 33 | 33 | import lombok.Setter; | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.anji.captcha.service.CaptchaCacheService
0 → 100644
yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.xingyuv.captcha.service.CaptchaCacheService deleted
| 1 | -cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl |
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java
| ... | ... | @@ -19,8 +19,8 @@ import cn.iocoder.yudao.module.system.service.member.MemberService; |
| 19 | 19 | import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; |
| 20 | 20 | import cn.iocoder.yudao.module.system.service.social.SocialUserService; |
| 21 | 21 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 22 | -import com.xingyuv.captcha.model.common.ResponseModel; | |
| 23 | -import com.xingyuv.captcha.service.CaptchaService; | |
| 22 | +import com.anji.captcha.model.common.ResponseModel; | |
| 23 | +import com.anji.captcha.service.CaptchaService; | |
| 24 | 24 | import jakarta.annotation.Resource; |
| 25 | 25 | import jakarta.validation.Validation; |
| 26 | 26 | import jakarta.validation.Validator; | ... | ... |