From 509a6e1a7303c38cf222313f4b140166987e5314 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 17 Oct 2020 09:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=B4=A6=E5=8F=B7=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=BB=98=E8=AE=A4=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=8F=8A=E5=AF=86=E7=A0=81=E6=9C=80=E5=90=8E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shiro/service/SysRegisterService.java | 17 ++++++++++------- .../resources/mapper/system/SysUserMapper.xml | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java index 97dfd1022..8cb61701d 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysRegisterService.java @@ -6,6 +6,7 @@ import org.springframework.util.StringUtils; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.ShiroConstants; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.framework.manager.AsyncManager; @@ -33,13 +34,13 @@ public class SysRegisterService */ public String register(SysUser user) { - String msg = "", username = user.getLoginName(), password = user.getPassword(); + String msg = "", loginName = user.getLoginName(), password = user.getPassword(); if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA))) { msg = "验证码错误"; } - else if (StringUtils.isEmpty(username)) + else if (StringUtils.isEmpty(loginName)) { msg = "用户名不能为空"; } @@ -52,17 +53,19 @@ public class SysRegisterService { msg = "密码长度必须在5到20个字符之间"; } - else if (username.length() < UserConstants.USERNAME_MIN_LENGTH - || username.length() > UserConstants.USERNAME_MAX_LENGTH) + else if (loginName.length() < UserConstants.USERNAME_MIN_LENGTH + || loginName.length() > UserConstants.USERNAME_MAX_LENGTH) { msg = "账户长度必须在2到20个字符之间"; } - else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(username))) + else if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(loginName))) { - msg = "保存用户'" + username + "'失败,注册账号已存在"; + msg = "保存用户'" + loginName + "'失败,注册账号已存在"; } else { + user.setPwdUpdateDate(DateUtils.getNowDate()); + user.setUserName(loginName); user.setSalt(ShiroUtils.randomSalt()); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); boolean regFlag = userService.registerUser(user); @@ -72,7 +75,7 @@ public class SysRegisterService } else { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success"))); + AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.REGISTER, MessageUtils.message("user.register.success"))); } } return msg; diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 7f1c18497..1ee58e8fa 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -200,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" password, salt, status, + pwd_update_date, create_by, remark, create_time @@ -216,6 +217,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{password}, #{salt}, #{status}, + #{pwdUpdateDate}, #{createBy}, #{remark}, sysdate()