feat: add user module register
This commit is contained in:
@@ -58,6 +58,15 @@ public class UUser extends BaseEntity
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 用户姓名 */
|
||||
private String fullName;
|
||||
|
||||
/** 年龄 */
|
||||
private Integer age;
|
||||
|
||||
/** 地址 */
|
||||
private String address;
|
||||
|
||||
/** 帐号状态(0正常 1停用) */
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
@@ -102,6 +111,30 @@ public class UUser extends BaseEntity
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
package org.wfc.user.controller;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.common.core.domain.R;
|
||||
@@ -23,7 +31,13 @@ import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.user.api.domain.UDept;
|
||||
import org.wfc.user.api.domain.URole;
|
||||
import org.wfc.user.api.domain.UUser;
|
||||
import org.wfc.user.service.*;
|
||||
import org.wfc.user.domain.query.UserRepeatQuery;
|
||||
import org.wfc.user.service.IUConfigService;
|
||||
import org.wfc.user.service.IUDeptService;
|
||||
import org.wfc.user.service.IUPermissionService;
|
||||
import org.wfc.user.service.IUPostService;
|
||||
import org.wfc.user.service.IURoleService;
|
||||
import org.wfc.user.service.IUUserService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -75,6 +89,18 @@ public class UUserController extends BaseController
|
||||
return MessageUtils.message("user.jcaptcha.error");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查重复
|
||||
*/
|
||||
@PostMapping("/checkRepeat")
|
||||
public R<Boolean> checkRepeat(@RequestBody UserRepeatQuery query)
|
||||
{
|
||||
UUser user = new UUser();
|
||||
BeanUtils.copyProperties(query, user);
|
||||
return R.ok(!userService.checkUserNameUnique(user) || !userService.checkPhoneUnique(user)
|
||||
|| !userService.checkEmailUnique(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@@ -144,18 +170,29 @@ public class UUserController extends BaseController
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/register")
|
||||
public R<Boolean> register(@RequestBody UUser UUser)
|
||||
public R<Boolean> register(@RequestBody UUser uUser)
|
||||
{
|
||||
String username = UUser.getUserName();
|
||||
if (!("true".equals(configService.selectConfigByKey("U.account.registerUser"))))
|
||||
String username = uUser.getUserName();
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||
{
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
if (!userService.checkUserNameUnique(UUser))
|
||||
if (!userService.checkUserNameUnique(uUser))
|
||||
{
|
||||
return R.fail("保存用户'" + username + "'失败,注册账号已存在");
|
||||
return R.fail("user.register.save.error");
|
||||
}
|
||||
return R.ok(userService.registerUser(UUser));
|
||||
|
||||
if (!userService.checkPhoneUnique(uUser))
|
||||
{
|
||||
return R.fail("user.register.phone.save.error");
|
||||
}
|
||||
|
||||
if (!userService.checkEmailUnique(uUser))
|
||||
{
|
||||
return R.fail("user.register.email.save.error");
|
||||
}
|
||||
|
||||
return R.ok(userService.registerUser(uUser));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.wfc.user.domain.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description: 用户重复query
|
||||
* @author: caiyuchao
|
||||
* @date: 2024-11-27
|
||||
*/
|
||||
@Data
|
||||
public class UserRepeatQuery {
|
||||
private String userName;
|
||||
private String email;
|
||||
private String phonenumber;
|
||||
}
|
||||
@@ -23,6 +23,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="fullName" column="full_name" />
|
||||
<result property="age" column="age" />
|
||||
<result property="address" column="address" />
|
||||
<association property="dept" javaType="UDept" resultMap="deptResult" />
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||
</resultMap>
|
||||
@@ -156,6 +159,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="fullName != null and fullName != ''">full_name,</if>
|
||||
<if test="age != null and age != ''">age,</if>
|
||||
<if test="address != null and address != ''">address,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
@@ -170,6 +176,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="fullName != null and fullName != ''">#{fullName},</if>
|
||||
<if test="age != null and age != ''">#{age},</if>
|
||||
<if test="address != null and address != ''">#{address},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
Reference in New Issue
Block a user