Skip to content

Commit

Permalink
Merge branch 'master-jdk21' of https://gitee.com/zhijiantianya/ruoyi-…
Browse files Browse the repository at this point in the history
…vue-pro

# Conflicts:
#	yudao-framework/yudao-spring-boot-starter-captcha/src/main/java/cn/iocoder/yudao/framework/captcha/config/YudaoCaptchaConfiguration.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/captcha/core/RedisCaptchaServiceImpl.java
  • Loading branch information
YunaiV committed Feb 28, 2024
2 parents 2dc7376 + 0317e42 commit 0dc23d3
Show file tree
Hide file tree
Showing 49 changed files with 48 additions and 133 deletions.
10 changes: 0 additions & 10 deletions yudao-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,6 @@
<artifactId>yudao-spring-boot-starter-biz-ip</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-captcha</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-desensitize</artifactId>
<version>${revision}</version>
</dependency>

<!-- Spring 核心 -->
<dependency>
Expand Down
1 change: 0 additions & 1 deletion yudao-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<module>yudao-spring-boot-starter-biz-ip</module>

<module>yudao-spring-boot-starter-flowable</module>
<module>yudao-spring-boot-starter-captcha</module>
<module>yudao-spring-boot-starter-websocket</module>
</modules>

Expand Down
38 changes: 0 additions & 38 deletions yudao-framework/yudao-spring-boot-starter-captcha/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions yudao-module-system/yudao-module-system-biz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>

<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-captcha</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
Expand Down Expand Up @@ -135,6 +130,11 @@
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java-sms</artifactId> <!-- 短信(腾讯云) -->
</dependency>

<dependency>
<groupId>com.xingyuv</groupId>
<artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 -->
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
* 验证码的配置类
*
* @author 芋道源码
*/
@Configuration(proxyBeanMethods = false)
public class YudaoCaptchaConfiguration {

@Bean
public CaptchaCacheService captchaCacheService(AjCaptchaProperties config,
StringRedisTemplate stringRedisTemplate) {
CaptchaCacheService captchaCacheService = CaptchaServiceFactory.getCache(config.getCacheType().name());
if (captchaCacheService instanceof RedisCaptchaServiceImpl) {
((RedisCaptchaServiceImpl) captchaCacheService).setStringRedisTemplate(stringRedisTemplate);
}
return captchaCacheService;
}

}
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
package cn.iocoder.yudao.framework.captcha.core.service;
package cn.iocoder.yudao.module.system.framework.captcha.core;

import com.xingyuv.captcha.service.CaptchaCacheService;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
* 基于 Redis 实现验证码的存储
*
* @author 星语
*/
@NoArgsConstructor // 保证 aj-captcha 的 SPI 创建
@AllArgsConstructor
@Setter
public class RedisCaptchaServiceImpl implements CaptchaCacheService {

@Resource // 保证 aj-captcha 的 SPI 创建时的注入
private StringRedisTemplate stringRedisTemplate;

@Override
public String type() {
return "redis";
}

public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplate) {
this.stringRedisTemplate = stringRedisTemplate;
}

@Override
public void set(String key, String value, long expiresInSeconds) {
stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* 验证码拓展
*
* 基于 aj-captcha 实现滑块验证码,文档:https://ajcaptcha.beliefteam.cn/captcha-doc/
*
* @author 星语
*/
package cn.iocoder.yudao.module.system.framework.captcha;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cn.iocoder.yudao.module.system.framework.captcha.core.RedisCaptchaServiceImpl
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public void testSendSmsCode() {
public void testSmsLogin_success() {
// 准备参数
String mobile = randomString();
String scene = randomString();
AuthSmsLoginReqVO reqVO = new AuthSmsLoginReqVO(mobile, scene);
String code = randomString();
AuthSmsLoginReqVO reqVO = new AuthSmsLoginReqVO(mobile, code);
// mock 方法(用户信息)
AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(1L));
when(userService.getUserByMobile(eq(mobile))).thenReturn(user);
Expand Down

0 comments on commit 0dc23d3

Please sign in to comment.