注册用户

dev.vehicle.gateway
法外狂徒张三 2024-09-30 09:54:59 +08:00
parent f1fc409573
commit e4e65c6448
1 changed files with 27 additions and 0 deletions

View File

@ -1,6 +1,10 @@
package com.muyu.system.controller;
import com.muyu.common.core.constant.Constants;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.constant.UserConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
@ -115,6 +119,29 @@ public class SysFirmController extends BaseController
// 设置创建者和状态
sysFirm.setCreateBy(SecurityUtils.getUsername());
if (StringUtils.isAnyBlank(sysFirm.getUserName(), sysFirm.getPassword())) {
throw new ServiceException("用户/密码必须填写");
}
if (sysFirm.getUserName().length() < UserConstants.USERNAME_MIN_LENGTH
|| sysFirm.getUserName().length() > UserConstants.USERNAME_MAX_LENGTH) {
throw new ServiceException("账户长度必须在2到20个字符之间");
}
if (sysFirm.getPassword().length() < UserConstants.PASSWORD_MIN_LENGTH
|| sysFirm.getPassword().length() > UserConstants.PASSWORD_MAX_LENGTH) {
throw new ServiceException("密码长度必须在5到20个字符之间");
}
// 注册用户信息
SysUser sysUser = new SysUser();
sysUser.setUserName(SecurityUtils.getUsername());
sysUser.setNickName(SecurityUtils.getUsername());
sysUser.setPassword(SecurityUtils.encryptPassword(sysFirm.getPassword()));
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
// if (Result.FAIL == registerResult.getCode()) {
// throw new ServiceException(registerResult.getMsg());
// }
// recordLogService.recordLogininfor(SecurityUtils.getUsername(), Constants.REGISTER, "注册成功");
//
// SysRole role = new SysRole();
//