注册账号设置默认用户名称及密码最后更新时间

pull/223/MERGE
RuoYi 2020-10-17 09:56:08 +08:00
parent 64c865cc70
commit 509a6e1a73
2 changed files with 12 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import org.springframework.util.StringUtils;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.ShiroConstants; import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.AsyncManager;
@ -33,13 +34,13 @@ public class SysRegisterService
*/ */
public String register(SysUser user) 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))) if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA)))
{ {
msg = "验证码错误"; msg = "验证码错误";
} }
else if (StringUtils.isEmpty(username)) else if (StringUtils.isEmpty(loginName))
{ {
msg = "用户名不能为空"; msg = "用户名不能为空";
} }
@ -52,17 +53,19 @@ public class SysRegisterService
{ {
msg = "密码长度必须在5到20个字符之间"; msg = "密码长度必须在5到20个字符之间";
} }
else if (username.length() < UserConstants.USERNAME_MIN_LENGTH else if (loginName.length() < UserConstants.USERNAME_MIN_LENGTH
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) || loginName.length() > UserConstants.USERNAME_MAX_LENGTH)
{ {
msg = "账户长度必须在2到20个字符之间"; 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 else
{ {
user.setPwdUpdateDate(DateUtils.getNowDate());
user.setUserName(loginName);
user.setSalt(ShiroUtils.randomSalt()); user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
boolean regFlag = userService.registerUser(user); boolean regFlag = userService.registerUser(user);
@ -72,7 +75,7 @@ public class SysRegisterService
} }
else 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; return msg;

View File

@ -200,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="password != null and password != ''">password,</if> <if test="password != null and password != ''">password,</if>
<if test="salt != null and salt != ''">salt,</if> <if test="salt != null and salt != ''">salt,</if>
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="pwdUpdateDate != null">pwd_update_date,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
create_time create_time
@ -216,6 +217,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="password != null and password != ''">#{password},</if> <if test="password != null and password != ''">#{password},</if>
<if test="salt != null and salt != ''">#{salt},</if> <if test="salt != null and salt != ''">#{salt},</if>
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="pwdUpdateDate != null">#{pwdUpdateDate},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
sysdate() sysdate()