From d7656535a2eab25ad306007e7a3ae3908f6e731f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 30 Apr 2025 15:01:19 +0800 Subject: [PATCH] =?UTF-8?q?reactor=EF=BC=9A=E4=BD=BF=E7=94=A8=20aj-captcha?= =?UTF-8?q?=20=E5=AE=98=E6=96=B9=201.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-dependencies/pom.xml | 8 ++++---- yudao-module-system/yudao-module-system-biz/pom.xml | 4 ++-- .../controller/admin/captcha/CaptchaController.java | 13 ++++++------- .../captcha/config/YudaoCaptchaConfiguration.java | 13 +++++++++---- .../captcha/core/RedisCaptchaServiceImpl.java | 4 ++-- .../system/service/auth/AdminAuthServiceImpl.java | 6 +++--- ...=> com.anji.captcha.service.CaptchaCacheService} | 2 +- .../service/auth/AdminAuthServiceImplTest.java | 4 ++-- 8 files changed, 29 insertions(+), 25 deletions(-) rename yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/{com.xingyuv.captcha.service.CaptchaCacheService => com.anji.captcha.service.CaptchaCacheService} (82%) diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 90ce8aef22..9dbe220a15 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -48,7 +48,7 @@ 7.0.1 - 2.0.3 + 1.4.0 1.18.3 1.18.36 1.6.3 @@ -535,9 +535,9 @@ - com.xingyuv - spring-boot-starter-captcha-plus - ${captcha-plus.version} + com.anji-plus + captcha-spring-boot-starter + ${anji-plus-captcha.version} diff --git a/yudao-module-system/yudao-module-system-biz/pom.xml b/yudao-module-system/yudao-module-system-biz/pom.xml index 06a6ae4a06..16c7f0b28c 100644 --- a/yudao-module-system/yudao-module-system-biz/pom.xml +++ b/yudao-module-system/yudao-module-system-biz/pom.xml @@ -115,8 +115,8 @@ - com.xingyuv - spring-boot-starter-captcha-plus + com.anji-plus + captcha-spring-boot-starter diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/captcha/CaptchaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/captcha/CaptchaController.java index 174c560c4e..92259da7cf 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/captcha/CaptchaController.java +++ b/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; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import com.xingyuv.captcha.model.common.ResponseModel; -import com.xingyuv.captcha.model.vo.CaptchaVO; -import com.xingyuv.captcha.service.CaptchaService; +import com.anji.captcha.model.common.ResponseModel; +import com.anji.captcha.model.vo.CaptchaVO; +import com.anji.captcha.service.CaptchaService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.annotation.security.PermitAll; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.Resource; -import jakarta.annotation.security.PermitAll; -import jakarta.servlet.http.HttpServletRequest; - @Tag(name = "管理后台 - 验证码") @RestController("adminCaptchaController") @RequestMapping("/system/captcha") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/config/YudaoCaptchaConfiguration.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/config/YudaoCaptchaConfiguration.java index 23c8d78be2..5db497e430 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/config/YudaoCaptchaConfiguration.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/config/YudaoCaptchaConfiguration.java @@ -1,11 +1,14 @@ package cn.iocoder.yudao.module.system.framework.captcha.config; import cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl; -import com.xingyuv.captcha.properties.AjCaptchaProperties; -import com.xingyuv.captcha.service.CaptchaCacheService; -import com.xingyuv.captcha.service.impl.CaptchaServiceFactory; +import com.anji.captcha.config.AjCaptchaAutoConfiguration; +import com.anji.captcha.properties.AjCaptchaProperties; +import com.anji.captcha.service.CaptchaCacheService; +import com.anji.captcha.service.impl.CaptchaServiceFactory; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.data.redis.core.StringRedisTemplate; /** @@ -14,9 +17,11 @@ import org.springframework.data.redis.core.StringRedisTemplate; * @author 芋道源码 */ @Configuration(proxyBeanMethods = false) +@ImportAutoConfiguration(AjCaptchaAutoConfiguration.class) // 目的:解决 aj-captcha 针对 SpringBoot 3.X 自动配置不生效的问题 public class YudaoCaptchaConfiguration { - @Bean + @Bean(name = "AjCaptchaCacheService") + @Primary public CaptchaCacheService captchaCacheService(AjCaptchaProperties config, StringRedisTemplate stringRedisTemplate) { CaptchaCacheService captchaCacheService = CaptchaServiceFactory.getCache(config.getCacheType().name()); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/RedisCaptchaServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/RedisCaptchaServiceImpl.java index d69b88ccfe..2e66a676b6 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/RedisCaptchaServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/RedisCaptchaServiceImpl.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.system.framework.captcha.core; -import com.xingyuv.captcha.service.CaptchaCacheService; +import com.anji.captcha.service.CaptchaCacheService; import lombok.Setter; import org.springframework.data.redis.core.StringRedisTemplate; @@ -28,7 +28,7 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService { @Override public boolean exists(String key) { - return Boolean.TRUE.equals(stringRedisTemplate.hasKey(key)); + return stringRedisTemplate.hasKey(key); } @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index 4b09980235..94e589de5e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/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; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; import cn.iocoder.yudao.module.system.service.social.SocialUserService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; +import com.anji.captcha.model.common.ResponseModel; +import com.anji.captcha.model.vo.CaptchaVO; +import com.anji.captcha.service.CaptchaService; import com.google.common.annotations.VisibleForTesting; -import com.xingyuv.captcha.model.common.ResponseModel; -import com.xingyuv.captcha.model.vo.CaptchaVO; -import com.xingyuv.captcha.service.CaptchaService; import jakarta.annotation.Resource; import jakarta.validation.Validator; import lombok.Setter; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.xingyuv.captcha.service.CaptchaCacheService b/yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.anji.captcha.service.CaptchaCacheService similarity index 82% rename from yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.xingyuv.captcha.service.CaptchaCacheService rename to yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.anji.captcha.service.CaptchaCacheService index 946ee59649..fa9d5b2820 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.xingyuv.captcha.service.CaptchaCacheService +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.anji.captcha.service.CaptchaCacheService @@ -1 +1 @@ -cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl +cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java index 151150bc5a..88b766fa8a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java +++ b/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; import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; import cn.iocoder.yudao.module.system.service.social.SocialUserService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import com.xingyuv.captcha.model.common.ResponseModel; -import com.xingyuv.captcha.service.CaptchaService; +import com.anji.captcha.model.common.ResponseModel; +import com.anji.captcha.service.CaptchaService; import jakarta.annotation.Resource; import jakarta.validation.Validation; import jakarta.validation.Validator;