Skip to content

Commit 54ba099

Browse files
committed
refactor(system/user): 优化创建用户代码
1 parent 950942a commit 54ba099

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

continew-system/src/main/java/top/continew/admin/system/controller/UserController.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import top.continew.starter.core.util.validation.ValidationUtils;
4545
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
4646
import top.continew.starter.extension.crud.enums.Api;
47-
import top.continew.starter.extension.crud.model.resp.IdResp;
4847

4948
import java.io.IOException;
5049

@@ -62,14 +61,6 @@
6261
Api.BATCH_DELETE, Api.EXPORT, Api.DICT})
6362
public class UserController extends BaseController<UserService, UserResp, UserDetailResp, UserQuery, UserReq> {
6463

65-
@Override
66-
@Operation(summary = "新增数据", description = "新增数据")
67-
public IdResp<Long> create(@RequestBody @Valid UserReq req) {
68-
String password = SecureUtils.decryptPasswordByRsaPrivateKey(req.getPassword(), "密码解密失败", true);
69-
req.setPassword(password);
70-
return super.create(req);
71-
}
72-
7364
@Operation(summary = "下载导入模板", description = "下载导入模板")
7465
@SaCheckPermission("system:user:import")
7566
@GetMapping(value = "/import/template", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)

continew-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import top.continew.admin.common.context.UserContextHolder;
6060
import top.continew.admin.common.enums.DisEnableStatusEnum;
6161
import top.continew.admin.common.enums.GenderEnum;
62+
import top.continew.admin.common.util.SecureUtils;
6263
import top.continew.admin.system.constant.SystemConstants;
6364
import top.continew.admin.system.enums.OptionCategoryEnum;
6465
import top.continew.admin.system.mapper.user.UserMapper;
@@ -135,6 +136,8 @@ public PageResp<UserResp> page(UserQuery query, PageQuery pageQuery) {
135136

136137
@Override
137138
public void beforeCreate(UserReq req) {
139+
String password = SecureUtils.decryptPasswordByRsaPrivateKey(req.getPassword(), "密码解密失败", true);
140+
req.setPassword(password);
138141
this.checkUsernameRepeat(req.getUsername(), null);
139142
this.checkEmailRepeat(req.getEmail(), null, "邮箱为 [{}] 的用户已存在");
140143
this.checkPhoneRepeat(req.getPhone(), null, "手机号为 [{}] 的用户已存在");
@@ -680,8 +683,9 @@ private void checkEmailRepeat(String email, Long id, String template) {
680683
/**
681684
* 检查手机号码是否重复
682685
*
683-
* @param phone 手机号码
684-
* @param id ID
686+
* @param phone 手机号码
687+
* @param id ID
688+
* @param template 提示模板
685689
*/
686690
private void checkPhoneRepeat(String phone, Long id, String template) {
687691
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && baseMapper.lambdaQuery()

0 commit comments

Comments
 (0)