feat: add user module register
This commit is contained in:
@@ -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