diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java index 8133f21d4..a5744865b 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java @@ -437,16 +437,12 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username") public R changePassword(UserDTO userDto) { - UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername()); - if (Objects.isNull(userVO)) { - return R.failed("用户不存在"); - } - + SysUser user = baseMapper.selectById(SecurityUtils.getUser().getId()); if (StrUtil.isEmpty(userDto.getPassword())) { return R.failed("原密码不能为空"); } - if (!ENCODER.matches(userDto.getPassword(), userVO.getPassword())) { + if (!ENCODER.matches(userDto.getPassword(), user.getPassword())) { log.info("原密码错误,修改个人信息失败:{}", userDto.getUsername()); return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR)); } @@ -456,8 +452,9 @@ public class SysUserServiceImpl extends ServiceImpl impl } String password = ENCODER.encode(userDto.getNewpassword1()); - this.update(Wrappers.lambdaUpdate().set(SysUser::getPassword, password).eq(SysUser::getUserId, - userVO.getUserId())); + this.update(Wrappers.lambdaUpdate() + .set(SysUser::getPassword, password) + .eq(SysUser::getUserId, user.getUserId())); return R.ok(); }