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;
|
||||
}
|
||||
Reference in New Issue
Block a user