mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-08 12:57:13 +08:00
refactor(system/user): 优化创建用户代码
This commit is contained in:
@@ -44,7 +44,6 @@ import top.continew.admin.system.service.UserService;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
import top.continew.starter.extension.crud.model.resp.IdResp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -62,14 +61,6 @@ import java.io.IOException;
|
||||
Api.BATCH_DELETE, Api.EXPORT, Api.DICT})
|
||||
public class UserController extends BaseController<UserService, UserResp, UserDetailResp, UserQuery, UserReq> {
|
||||
|
||||
@Override
|
||||
@Operation(summary = "新增数据", description = "新增数据")
|
||||
public IdResp<Long> create(@RequestBody @Valid UserReq req) {
|
||||
String password = SecureUtils.decryptPasswordByRsaPrivateKey(req.getPassword(), "密码解密失败", true);
|
||||
req.setPassword(password);
|
||||
return super.create(req);
|
||||
}
|
||||
|
||||
@Operation(summary = "下载导入模板", description = "下载导入模板")
|
||||
@SaCheckPermission("system:user:import")
|
||||
@GetMapping(value = "/import/template", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
|
@@ -59,6 +59,7 @@ import top.continew.admin.common.context.UserContext;
|
||||
import top.continew.admin.common.context.UserContextHolder;
|
||||
import top.continew.admin.common.enums.DisEnableStatusEnum;
|
||||
import top.continew.admin.common.enums.GenderEnum;
|
||||
import top.continew.admin.common.util.SecureUtils;
|
||||
import top.continew.admin.system.constant.SystemConstants;
|
||||
import top.continew.admin.system.enums.OptionCategoryEnum;
|
||||
import top.continew.admin.system.mapper.user.UserMapper;
|
||||
@@ -135,6 +136,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
|
||||
@Override
|
||||
public void beforeCreate(UserReq req) {
|
||||
String password = SecureUtils.decryptPasswordByRsaPrivateKey(req.getPassword(), "密码解密失败", true);
|
||||
req.setPassword(password);
|
||||
this.checkUsernameRepeat(req.getUsername(), null);
|
||||
this.checkEmailRepeat(req.getEmail(), null, "邮箱为 [{}] 的用户已存在");
|
||||
this.checkPhoneRepeat(req.getPhone(), null, "手机号为 [{}] 的用户已存在");
|
||||
@@ -680,8 +683,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
|
||||
/**
|
||||
* 检查手机号码是否重复
|
||||
*
|
||||
* @param phone 手机号码
|
||||
* @param id ID
|
||||
* @param phone 手机号码
|
||||
* @param id ID
|
||||
* @param template 提示模板
|
||||
*/
|
||||
private void checkPhoneRepeat(String phone, Long id, String template) {
|
||||
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && baseMapper.lambdaQuery()
|
||||
|
Reference in New Issue
Block a user