Commit d7656535a2eab25ad306007e7a3ae3908f6e731f

Authored by YunaiV
1 parent 4cebe4af

reactor:使用 aj-captcha 官方 1.4.0

yudao-dependencies/pom.xml
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 <!-- Bpm 工作流相关 --> 48 <!-- Bpm 工作流相关 -->
49 <flowable.version>7.0.1</flowable.version> 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 <jsoup.version>1.18.3</jsoup.version> 52 <jsoup.version>1.18.3</jsoup.version>
53 <lombok.version>1.18.36</lombok.version> 53 <lombok.version>1.18.36</lombok.version>
54 <mapstruct.version>1.6.3</mapstruct.version> 54 <mapstruct.version>1.6.3</mapstruct.version>
@@ -535,9 +535,9 @@ @@ -535,9 +535,9 @@
535 </dependency> 535 </dependency>
536 536
537 <dependency> 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 </dependency> 541 </dependency>
542 542
543 <dependency> 543 <dependency>
yudao-module-system/yudao-module-system-biz/pom.xml
@@ -115,8 +115,8 @@ @@ -115,8 +115,8 @@
115 </dependency> 115 </dependency>
116 116
117 <dependency> 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 </dependency> 120 </dependency>
121 121
122 <dependency> 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,20 +2,19 @@ package cn.iocoder.yudao.module.system.controller.admin.captcha;
2 2
3 import cn.hutool.core.util.StrUtil; 3 import cn.hutool.core.util.StrUtil;
4 import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; 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 import io.swagger.v3.oas.annotations.Operation; 8 import io.swagger.v3.oas.annotations.Operation;
9 import io.swagger.v3.oas.annotations.tags.Tag; 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 import org.springframework.web.bind.annotation.PostMapping; 13 import org.springframework.web.bind.annotation.PostMapping;
11 import org.springframework.web.bind.annotation.RequestBody; 14 import org.springframework.web.bind.annotation.RequestBody;
12 import org.springframework.web.bind.annotation.RequestMapping; 15 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RestController; 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 @Tag(name = "管理后台 - 验证码") 18 @Tag(name = "管理后台 - 验证码")
20 @RestController("adminCaptchaController") 19 @RestController("adminCaptchaController")
21 @RequestMapping("/system/captcha") 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 package cn.iocoder.yudao.module.system.framework.captcha.config; 1 package cn.iocoder.yudao.module.system.framework.captcha.config;
2 2
3 import cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl; 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 import org.springframework.context.annotation.Bean; 9 import org.springframework.context.annotation.Bean;
8 import org.springframework.context.annotation.Configuration; 10 import org.springframework.context.annotation.Configuration;
  11 +import org.springframework.context.annotation.Primary;
9 import org.springframework.data.redis.core.StringRedisTemplate; 12 import org.springframework.data.redis.core.StringRedisTemplate;
10 13
11 /** 14 /**
@@ -14,9 +17,11 @@ import org.springframework.data.redis.core.StringRedisTemplate; @@ -14,9 +17,11 @@ import org.springframework.data.redis.core.StringRedisTemplate;
14 * @author 芋道源码 17 * @author 芋道源码
15 */ 18 */
16 @Configuration(proxyBeanMethods = false) 19 @Configuration(proxyBeanMethods = false)
  20 +@ImportAutoConfiguration(AjCaptchaAutoConfiguration.class) // 目的:解决 aj-captcha 针对 SpringBoot 3.X 自动配置不生效的问题
17 public class YudaoCaptchaConfiguration { 21 public class YudaoCaptchaConfiguration {
18 22
19 - @Bean 23 + @Bean(name = "AjCaptchaCacheService")
  24 + @Primary
20 public CaptchaCacheService captchaCacheService(AjCaptchaProperties config, 25 public CaptchaCacheService captchaCacheService(AjCaptchaProperties config,
21 StringRedisTemplate stringRedisTemplate) { 26 StringRedisTemplate stringRedisTemplate) {
22 CaptchaCacheService captchaCacheService = CaptchaServiceFactory.getCache(config.getCacheType().name()); 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 package cn.iocoder.yudao.module.system.framework.captcha.core; 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 import lombok.Setter; 4 import lombok.Setter;
5 import org.springframework.data.redis.core.StringRedisTemplate; 5 import org.springframework.data.redis.core.StringRedisTemplate;
6 6
@@ -28,7 +28,7 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService { @@ -28,7 +28,7 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService {
28 28
29 @Override 29 @Override
30 public boolean exists(String key) { 30 public boolean exists(String key) {
31 - return Boolean.TRUE.equals(stringRedisTemplate.hasKey(key)); 31 + return stringRedisTemplate.hasKey(key);
32 } 32 }
33 33
34 @Override 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,10 +24,10 @@ import cn.iocoder.yudao.module.system.service.member.MemberService;
24 import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; 24 import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
25 import cn.iocoder.yudao.module.system.service.social.SocialUserService; 25 import cn.iocoder.yudao.module.system.service.social.SocialUserService;
26 import cn.iocoder.yudao.module.system.service.user.AdminUserService; 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 import com.google.common.annotations.VisibleForTesting; 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 import jakarta.annotation.Resource; 31 import jakarta.annotation.Resource;
32 import jakarta.validation.Validator; 32 import jakarta.validation.Validator;
33 import lombok.Setter; 33 import lombok.Setter;
yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.anji.captcha.service.CaptchaCacheService 0 → 100644
  1 +cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl
0 \ No newline at end of file 2 \ No newline at end of file
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,8 +19,8 @@ import cn.iocoder.yudao.module.system.service.member.MemberService;
19 import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; 19 import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
20 import cn.iocoder.yudao.module.system.service.social.SocialUserService; 20 import cn.iocoder.yudao.module.system.service.social.SocialUserService;
21 import cn.iocoder.yudao.module.system.service.user.AdminUserService; 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 import jakarta.annotation.Resource; 24 import jakarta.annotation.Resource;
25 import jakarta.validation.Validation; 25 import jakarta.validation.Validation;
26 import jakarta.validation.Validator; 26 import jakarta.validation.Validator;