From d97533ff7c7103008a4ceb240458ada39f833d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Tue, 19 Mar 2024 16:15:15 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20#I99Q0B=20bug?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=20=E5=A4=9A=E8=A7=92=E8=89=B2=20=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=9B=B4=E6=96=B0=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pig/admin/service/impl/SysUserServiceImpl.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java index 2dbffbc0..b3306625 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java @@ -204,11 +204,9 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username") public R updateUserInfo(UserDTO userDto) { - UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername()); - SysUser sysUser = new SysUser(); sysUser.setPhone(userDto.getPhone()); - sysUser.setUserId(userVO.getUserId()); + sysUser.setUserId(SecurityUtils.getUser().getId()); sysUser.setAvatar(userDto.getAvatar()); sysUser.setNickname(userDto.getNickname()); sysUser.setName(userDto.getName()); @@ -259,7 +257,7 @@ public class SysUserServiceImpl extends ServiceImpl impl // 根据数据权限查询全部的用户信息 List voList = baseMapper.selectVoList(userDTO); // 转换成execl 对象输出 - List userExcelVOList = voList.stream().map(userVO -> { + return voList.stream().map(userVO -> { UserExcelVO excelVO = new UserExcelVO(); BeanUtils.copyProperties(userVO, excelVO); String roleNameList = userVO.getRoleList() @@ -412,8 +410,8 @@ 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)) { + SysUser sysUser = baseMapper.selectById(SecurityUtils.getUser().getId()); + if (Objects.isNull(sysUser)) { return R.failed("用户不存在"); } @@ -421,7 +419,7 @@ public class SysUserServiceImpl extends ServiceImpl impl return R.failed("原密码不能为空"); } - if (!ENCODER.matches(userDto.getPassword(), userVO.getPassword())) { + if (!ENCODER.matches(userDto.getPassword(), sysUser.getPassword())) { log.info("原密码错误,修改个人信息失败:{}", userDto.getUsername()); return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR)); } @@ -433,7 +431,7 @@ public class SysUserServiceImpl extends ServiceImpl impl this.update(Wrappers.lambdaUpdate() .set(SysUser::getPassword, password) - .eq(SysUser::getUserId, userVO.getUserId())); + .eq(SysUser::getUserId, sysUser.getUserId())); return R.ok(); }