mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
feat(profile): 允许用户修改用户名(loginCode)
- 后端 UpdateUserInfoDTO 新增 loginCode 字段 - 后端 Service 层新增 loginCode 唯一性检查,已被使用则报错 - 前端表单支持编辑用户名 - 前端 DTO 类型同步更新
This commit is contained in:
+5
@@ -9,6 +9,11 @@ import lombok.Data;
|
||||
@Data
|
||||
public class UpdateUserInfoDTO {
|
||||
|
||||
/**
|
||||
* 登录账号(用户名)
|
||||
*/
|
||||
private String loginCode;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
|
||||
+13
@@ -211,7 +211,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
}
|
||||
}
|
||||
|
||||
// 检查登录账号是否已被其他用户使用
|
||||
if (StringUtils.hasText(updateUserInfoDTO.getLoginCode()) &&
|
||||
!updateUserInfoDTO.getLoginCode().equals(user.getLoginCode())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getLoginCode, updateUserInfoDTO.getLoginCode());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("登录账号已被其他用户使用");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新用户信息
|
||||
if (StringUtils.hasText(updateUserInfoDTO.getLoginCode())) {
|
||||
user.setLoginCode(updateUserInfoDTO.getLoginCode());
|
||||
}
|
||||
if (StringUtils.hasText(updateUserInfoDTO.getRealName())) {
|
||||
user.setRealName(updateUserInfoDTO.getRealName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user