From 76640d343082d1473a482e7ba48461db9b26c035 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 30 四月 2026 17:36:57 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_pro
---
src/main/java/com/ruoyi/framework/security/service/SysRegisterService.java | 36 ++++++++++++++++--------------------
1 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/ruoyi/framework/security/service/SysRegisterService.java b/src/main/java/com/ruoyi/framework/security/service/SysRegisterService.java
index 9734fe2..e139835 100644
--- a/src/main/java/com/ruoyi/framework/security/service/SysRegisterService.java
+++ b/src/main/java/com/ruoyi/framework/security/service/SysRegisterService.java
@@ -1,14 +1,13 @@
package com.ruoyi.framework.security.service;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
+import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.CaptchaExpireException;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.framework.redis.RedisCache;
@@ -16,6 +15,8 @@
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysConfigService;
import com.ruoyi.project.system.service.ISysUserService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
/**
* 娉ㄥ唽鏍¢獙鏂规硶
@@ -23,16 +24,12 @@
* @author ruoyi
*/
@Component
+@RequiredArgsConstructor
public class SysRegisterService
{
- @Autowired
- private ISysUserService userService;
-
- @Autowired
- private ISysConfigService configService;
-
- @Autowired
- private RedisCache redisCache;
+ private final ISysUserService userService;
+ private final ISysConfigService configService;
+ private final RedisCache redisCache;
/**
* 娉ㄥ唽
@@ -40,10 +37,12 @@
public String register(RegisterBody registerBody)
{
String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
+ SysUser sysUser = new SysUser();
+ sysUser.setUserName(username);
- boolean captchaOnOff = configService.selectCaptchaOnOff();
// 楠岃瘉鐮佸紑鍏�
- if (captchaOnOff)
+ boolean captchaEnabled = configService.selectCaptchaEnabled();
+ if (captchaEnabled)
{
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
}
@@ -66,16 +65,14 @@
{
msg = "瀵嗙爜闀垮害蹇呴』鍦�5鍒�20涓瓧绗︿箣闂�";
}
- else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
+ else if (!userService.checkUserNameUnique(sysUser))
{
msg = "淇濆瓨鐢ㄦ埛'" + username + "'澶辫触锛屾敞鍐岃处鍙峰凡瀛樺湪";
}
else
{
- SysUser sysUser = new SysUser();
- sysUser.setUserName(username);
sysUser.setNickName(username);
- sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
+ sysUser.setPassword(SecurityUtils.encryptPassword(password));
boolean regFlag = userService.registerUser(sysUser);
if (!regFlag)
{
@@ -83,8 +80,7 @@
}
else
{
- AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER,
- MessageUtils.message("user.register.success")));
+ AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success")));
}
}
return msg;
@@ -100,7 +96,7 @@
*/
public void validateCaptcha(String username, String code, String uuid)
{
- String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
+ String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
--
Gitblit v1.9.3