feat: add user module register
This commit is contained in:
@@ -5,24 +5,22 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.web.form.LoginBody;
|
||||
import org.wfc.common.core.web.form.RegisterBody;
|
||||
import org.wfc.auth.service.SysLoginService;
|
||||
import org.wfc.auth.service.ULoginService;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.common.core.domain.R;
|
||||
import org.wfc.common.core.utils.JwtUtils;
|
||||
import org.wfc.common.core.utils.StringUtils;
|
||||
import org.wfc.common.core.web.form.LoginBody;
|
||||
import org.wfc.common.core.web.form.RegisterBody;
|
||||
import org.wfc.common.security.auth.AuthUtil;
|
||||
import org.wfc.common.security.service.TokenService;
|
||||
import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.system.api.domain.SysUser;
|
||||
import org.wfc.user.api.domain.UUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* token 控制
|
||||
*
|
||||
@@ -89,8 +87,9 @@ public class TokenController
|
||||
@PostMapping("register")
|
||||
public R<?> register(@RequestBody RegisterBody registerBody)
|
||||
{
|
||||
// 用户注册
|
||||
sysLoginService.register(registerBody);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.wfc.auth.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.wfc.common.core.constant.CacheConstants;
|
||||
@@ -21,6 +22,8 @@ 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.user.api.RemoteUUserService;
|
||||
import org.wfc.user.api.domain.UUser;
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
@@ -33,6 +36,9 @@ public class SysLoginService
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Autowired
|
||||
private RemoteUUserService remoteUUserService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@@ -161,12 +167,23 @@ public class SysLoginService
|
||||
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());
|
||||
if ("u".equals(registerBody.getAuthType())){
|
||||
UUser uUser = new UUser();
|
||||
BeanUtils.copyProperties(sysUser, uUser);
|
||||
R<?> registerResult = remoteUUserService.registerUserInfo(uUser, SecurityConstants.INNER);
|
||||
if (R.FAIL == registerResult.getCode())
|
||||
{
|
||||
throw new ServiceException(registerResult.getMsg());
|
||||
}
|
||||
} if ("sys".equals(registerBody.getAuthType())){
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user