feat: add register
This commit is contained in:
@@ -21,6 +21,8 @@ import org.wfc.user.api.domain.UUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* token 控制
|
||||
*
|
||||
@@ -88,7 +90,7 @@ public class TokenController
|
||||
public R<?> register(@RequestBody RegisterBody registerBody)
|
||||
{
|
||||
// 用户注册
|
||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||
sysLoginService.register(registerBody);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.wfc.auth.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.wfc.common.core.constant.CacheConstants;
|
||||
import org.wfc.common.core.constant.Constants;
|
||||
import org.wfc.common.core.constant.GlobalConstants;
|
||||
import org.wfc.common.core.constant.SecurityConstants;
|
||||
import org.wfc.common.core.constant.UserConstants;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.common.core.domain.R;
|
||||
import org.wfc.common.core.enums.UserStatus;
|
||||
import org.wfc.common.core.exception.ServiceException;
|
||||
@@ -13,12 +16,11 @@ import org.wfc.common.core.text.Convert;
|
||||
import org.wfc.common.core.utils.DateUtils;
|
||||
import org.wfc.common.core.utils.StringUtils;
|
||||
import org.wfc.common.core.utils.ip.IpUtils;
|
||||
import org.wfc.common.core.web.form.RegisterBody;
|
||||
import org.wfc.common.redis.service.RedisService;
|
||||
import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.system.api.RemoteUserService;
|
||||
import org.wfc.system.api.domain.SysUser;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.user.api.domain.UUser;
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
@@ -128,8 +130,10 @@ public class SysLoginService
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(String username, String password)
|
||||
public void register(RegisterBody registerBody)
|
||||
{
|
||||
String username = registerBody.getUsername();
|
||||
String password = registerBody.getPassword();
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password))
|
||||
{
|
||||
@@ -151,12 +155,22 @@ public class SysLoginService
|
||||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
sysUser.setAge(registerBody.getAge());
|
||||
sysUser.setAddress(registerBody.getAddress());
|
||||
sysUser.setEmail(registerBody.getEmail());
|
||||
sysUser.setFullName(registerBody.getFullName());
|
||||
sysUser.setSex(registerBody.getSex());
|
||||
sysUser.setPhonenumber(registerBody.getPhonenumber());
|
||||
R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||
|
||||
if (R.FAIL == registerResult.getCode())
|
||||
{
|
||||
throw new ServiceException(registerResult.getMsg());
|
||||
}
|
||||
// 注册成功删除redis
|
||||
if (StrUtil.isNotBlank(registerBody.getEmail())) {
|
||||
redisService.deleteObject(GlobalConstants.CAPTCHA_CODE_KEY + registerBody.getEmail());
|
||||
}
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user