Commit 0317e4279d28704c6f0cecbc8e2fce0febc1277a

Authored by YunaiV
1 parent 0480cdf0

✨ 全局:简化 captcha 组件,融合到 system 模块

Showing 48 changed files with 43 additions and 128 deletions
yudao-dependencies/pom.xml
... ... @@ -131,16 +131,6 @@
131 131 <artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
132 132 <version>${revision}</version>
133 133 </dependency>
134   - <dependency>
135   - <groupId>cn.iocoder.boot</groupId>
136   - <artifactId>yudao-spring-boot-starter-captcha</artifactId>
137   - <version>${revision}</version>
138   - </dependency>
139   - <dependency>
140   - <groupId>cn.iocoder.boot</groupId>
141   - <artifactId>yudao-spring-boot-starter-desensitize</artifactId>
142   - <version>${revision}</version>
143   - </dependency>
144 134  
145 135 <!-- Spring 核心 -->
146 136 <dependency>
... ...
yudao-framework/pom.xml
... ... @@ -33,7 +33,6 @@
33 33 <module>yudao-spring-boot-starter-biz-ip</module>
34 34  
35 35 <module>yudao-spring-boot-starter-flowable</module>
36   - <module>yudao-spring-boot-starter-captcha</module>
37 36 <module>yudao-spring-boot-starter-websocket</module>
38 37 </modules>
39 38  
... ...
yudao-framework/yudao-spring-boot-starter-captcha/pom.xml deleted
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5   - <parent>
6   - <groupId>cn.iocoder.boot</groupId>
7   - <artifactId>yudao-framework</artifactId>
8   - <version>${revision}</version>
9   - </parent>
10   - <modelVersion>4.0.0</modelVersion>
11   - <artifactId>yudao-spring-boot-starter-captcha</artifactId>
12   - <packaging>jar</packaging>
13   -
14   - <name>${project.artifactId}</name>
15   - <description>验证码拓展
16   - 1. 基于 aj-captcha 实现滑块验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/
17   - </description>
18   -
19   - <dependencies>
20   - <dependency>
21   - <groupId>com.xingyuv</groupId>
22   - <artifactId>spring-boot-starter-captcha-plus</artifactId>
23   - </dependency>
24   - <!-- Spring 核心 -->
25   - <dependency>
26   - <groupId>org.springframework.boot</groupId>
27   - <artifactId>spring-boot-starter</artifactId>
28   - </dependency>
29   -
30   - <!-- DB 相关 -->
31   - <dependency>
32   - <groupId>cn.iocoder.boot</groupId>
33   - <artifactId>yudao-spring-boot-starter-redis</artifactId>
34   - </dependency>
35   -
36   - </dependencies>
37   -
38   -</project>
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java deleted
1   -package cn.iocoder.yudao.framework.captcha.config;
2   -
3   -import cn.iocoder.yudao.framework.captcha.core.service.RedisCaptchaServiceImpl;
4   -import com.xingyuv.captcha.properties.AjCaptchaProperties;
5   -import com.xingyuv.captcha.service.CaptchaCacheService;
6   -import com.xingyuv.captcha.service.impl.CaptchaServiceFactory;
7   -import org.springframework.boot.autoconfigure.AutoConfiguration;
8   -import org.springframework.context.annotation.Bean;
9   -import org.springframework.data.redis.core.StringRedisTemplate;
10   -
11   -import jakarta.annotation.Resource;
12   -
13   -@AutoConfiguration
14   -public class YudaoCaptchaConfiguration {
15   -
16   - @Resource
17   - private StringRedisTemplate stringRedisTemplate;
18   -
19   - @Bean
20   - public CaptchaCacheService captchaCacheService(AjCaptchaProperties config) {
21   - // 缓存类型 redis/local/....
22   - CaptchaCacheService ret = CaptchaServiceFactory.getCache(config.getCacheType().name());
23   - if (ret instanceof RedisCaptchaServiceImpl) {
24   - ((RedisCaptchaServiceImpl) ret).setStringRedisTemplate(stringRedisTemplate);
25   - }
26   - return ret;
27   - }
28   -
29   -}
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/enums/CaptchaRedisKeyConstants.java deleted
1   -package cn.iocoder.yudao.framework.captcha.core.enums;
2   -
3   -/**
4   - * 验证码 Redis Key 枚举类
5   - *
6   - * @author 芋道源码
7   - */
8   -public interface CaptchaRedisKeyConstants {
9   -
10   - /**
11   - * 验证码的请求限流
12   - *
13   - * KEY 格式:AJ.CAPTCHA.REQ.LIMIT-%s-%s
14   - * VALUE 数据类型:String // 例如说:验证失败 5 次,get 接口锁定
15   - * 过期时间:60 秒
16   - */
17   - String AJ_CAPTCHA_REQ_LIMIT = "AJ.CAPTCHA.REQ.LIMIT-%s-%s";
18   -
19   - /**
20   - * 验证码的坐标
21   - *
22   - * KEY 格式:RUNNING:CAPTCHA:%s // AbstractCaptchaService.REDIS_CAPTCHA_KEY
23   - * VALUE 数据类型:String // PointVO.class {"secretKey":"PP1w2Frr2KEejD2m","x":162,"y":5}
24   - * 过期时间:120 秒
25   - */
26   - String AJ_CAPTCHA_RUNNING = "RUNNING:CAPTCHA:%s";
27   -
28   -}
yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/META-INF/services/com.xingyuv.captcha.service.CaptchaCacheService deleted
1   -cn.iocoder.yudao.framework.captcha.core.service.RedisCaptchaServiceImpl
yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted
1   -cn.iocoder.yudao.framework.captcha.config.YudaoCaptchaConfiguration
2 0 \ No newline at end of file
yudao-module-system/yudao-module-system-biz/pom.xml
... ... @@ -99,11 +99,6 @@
99 99 </dependency>
100 100  
101 101 <dependency>
102   - <groupId>cn.iocoder.boot</groupId>
103   - <artifactId>yudao-spring-boot-starter-captcha</artifactId>
104   - </dependency>
105   -
106   - <dependency>
107 102 <groupId>org.springframework.boot</groupId>
108 103 <artifactId>spring-boot-starter-mail</artifactId>
109 104 </dependency>
... ... @@ -135,6 +130,11 @@
135 130 <groupId>com.tencentcloudapi</groupId>
136 131 <artifactId>tencentcloud-sdk-java-sms</artifactId> <!-- 短信(腾讯云) -->
137 132 </dependency>
  133 +
  134 + <dependency>
  135 + <groupId>com.xingyuv</groupId>
  136 + <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
  137 + </dependency>
138 138 </dependencies>
139 139  
140 140 </project>
... ...
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/config/YudaoCaptchaConfiguration.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.framework.captcha.config;
  2 +
  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;
  7 +import org.springframework.context.annotation.Bean;
  8 +import org.springframework.context.annotation.Configuration;
  9 +import org.springframework.data.redis.core.StringRedisTemplate;
  10 +
  11 +/**
  12 + * 验证码的配置类
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@Configuration(proxyBeanMethods = false)
  17 +public class YudaoCaptchaConfiguration {
  18 +
  19 + @Bean
  20 + public CaptchaCacheService captchaCacheService(AjCaptchaProperties config,
  21 + StringRedisTemplate stringRedisTemplate) {
  22 + CaptchaCacheService captchaCacheService = CaptchaServiceFactory.getCache(config.getCacheType().name());
  23 + if (captchaCacheService instanceof RedisCaptchaServiceImpl) {
  24 + ((RedisCaptchaServiceImpl) captchaCacheService).setStringRedisTemplate(stringRedisTemplate);
  25 + }
  26 + return captchaCacheService;
  27 + }
  28 +
  29 +}
... ...
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/core/service/RedisCaptchaServiceImpl.java renamed to 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.framework.captcha.core.service;
  1 +package cn.iocoder.yudao.module.system.framework.captcha.core;
2 2  
3 3 import com.xingyuv.captcha.service.CaptchaCacheService;
4   -import lombok.AllArgsConstructor;
5   -import lombok.NoArgsConstructor;
  4 +import lombok.Setter;
6 5 import org.springframework.data.redis.core.StringRedisTemplate;
7 6  
8   -import jakarta.annotation.Resource;
9 7 import java.util.concurrent.TimeUnit;
10 8  
11 9 /**
... ... @@ -13,11 +11,9 @@ import java.util.concurrent.TimeUnit;
13 11 *
14 12 * @author 星语
15 13 */
16   -@NoArgsConstructor // 保证 aj-captcha 的 SPI 创建
17   -@AllArgsConstructor
  14 +@Setter
18 15 public class RedisCaptchaServiceImpl implements CaptchaCacheService {
19 16  
20   - @Resource // 保证 aj-captcha 的 SPI 创建时的注入
21 17 private StringRedisTemplate stringRedisTemplate;
22 18  
23 19 @Override
... ... @@ -25,10 +21,6 @@ public class RedisCaptchaServiceImpl implements CaptchaCacheService {
25 21 return "redis";
26 22 }
27 23  
28   - public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) {
29   - this.stringRedisTemplate = stringRedisTemplate;
30   - }
31   -
32 24 @Override
33 25 public void set(String key, String value, long expiresInSeconds) {
34 26 stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
... ...
yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/package-info.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/package-info.java
1 1 /**
2 2 * 验证码拓展
3   - * 1. 基于 aj-captcha 实现滑块验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/
  3 + *
  4 + * 基于 aj-captcha 实现滑块验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/
4 5 *
5 6 * @author 星语
6 7 */
7   -package cn.iocoder.yudao.framework.captcha;
  8 +package cn.iocoder.yudao.module.system.framework.captcha;
8 9 \ No newline at end of file
... ...
yudao-module-system/yudao-module-system-biz/src/main/resources/META-INF/services/com.xingyuv.captcha.service.CaptchaCacheService 0 → 100644
  1 +cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl
... ...
yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg1.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg1.png

17.4 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg2.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg2.png

28.1 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg3.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg3.png

25.2 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg4.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg4.png

27.2 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg5.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg5.png

23.5 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg6.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg6.png

18.7 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg7.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg7.png

20.9 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg8.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg8.png

29.6 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/original/bg9.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/original/bg9.png

26.3 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/1.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/1.png

2.11 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/10.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/10.png

1.62 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/11.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/11.png

1.62 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/12.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/12.png

1.62 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/13.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/13.png

1.83 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/14.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/14.png

1.83 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/15.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/15.png

1.83 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/16.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/16.png

1.79 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/17.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/17.png

1.8 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/18.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/18.png

1.79 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/19.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/19.png

1.79 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/8.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/8.png

1.62 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/11/9.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/11/9.png

1.62 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/2.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/2.png

2.24 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/3.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/3.png

2.19 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/jigsaw/slidingBlock/4.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/jigsaw/slidingBlock/4.png

2.2 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg1.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg1.png

23.5 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg10.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg10.png

27.2 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg2.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg2.png

27.7 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg3.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg3.png

22.9 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg4.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg4.png

24.8 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg5.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg5.png

16 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg6.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg6.png

23.1 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg7.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg7.png

25.5 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg8.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg8.png

26.6 KB

yudao-framework/yudao-spring-boot-starter-captcha/src/main/resources/images/pic-click/bg9.png renamed to yudao-module-system/yudao-module-system-biz/src/main/resources/images/pic-click/bg9.png

29.2 KB

yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java
... ... @@ -207,8 +207,8 @@ public class AdminAuthServiceImplTest extends BaseDbUnitTest {
207 207 public void testSmsLogin_success() {
208 208 // 准备参数
209 209 String mobile = randomString();
210   - String scene = randomString();
211   - AuthSmsLoginReqVO reqVO = new AuthSmsLoginReqVO(mobile, scene);
  210 + String code = randomString();
  211 + AuthSmsLoginReqVO reqVO = new AuthSmsLoginReqVO(mobile, code);
212 212 // mock 方法(用户信息)
213 213 AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(1L));
214 214 when(userService.getUserByMobile(eq(mobile))).thenReturn(user);
... ...