1.修改用户更新逻辑

This commit is contained in:
2025-08-05 22:04:36 +08:00
parent 65c41326f4
commit fda3e45dc6

View File

@@ -85,7 +85,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserModel> implements
throw new BusinessException(ErrorCode.USER_DOES_NOT_EXIST);
}
// 用户没有密码的情况下设置密码
if (userInfo.getPassword() == null) {
if (userInfo.getPassword() == null && userModelDTO.getNewPassword() != null) {
if (!userModelDTO.getNewPassword().isEmpty()){
if (userModelDTO.getNewPassword().length()<6){
throw new BusinessException(ErrorCode.PARAMS_ERROR,"密码长度不能小于 6 位");
@@ -106,12 +106,11 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserModel> implements
}
}
UserModel userModel = new UserModel();
BeanUtil.copyProperties(userModelDTO, userModel);
UserModel userModel = BeanUtil.copyProperties(userModelDTO, UserModel.class);
int i = userDao.updateById(userModel);
// 返回结果
userDao.selectById(userModel.getId());
UserModelVO userModelVO = BeanUtil.copyProperties(userModel, UserModelVO.class);
UserModel afterUserInfo = userDao.selectById(userModel.getId());
UserModelVO userModelVO = BeanUtil.copyProperties(afterUserInfo, UserModelVO.class);
userModelVO.setNewAccount(false);
if (i == 1){
return userModelVO;