Skip to content

Commit

Permalink
🐛 Fixing a bug. #I99Q0B bug提交 多角色 无法更新个人信息
Browse files Browse the repository at this point in the history
  • Loading branch information
lltx committed Mar 19, 2024
1 parent a00e346 commit a352009
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ public Boolean deleteUserByIds(Long[] ids) {
@Override
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
public R<Boolean> updateUserInfo(UserDTO userDto) {
UserVO userVO = baseMapper.getUserVoById(SecurityUtils.getUser().getId());

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());
Expand Down Expand Up @@ -259,7 +257,7 @@ public List<UserExcelVO> listUser(UserDTO userDTO) {
// 根据数据权限查询全部的用户信息
List<UserVO> voList = baseMapper.selectVoList(userDTO);
// 转换成execl 对象输出
List<UserExcelVO> userExcelVOList = voList.stream().map(userVO -> {
return voList.stream().map(userVO -> {
UserExcelVO excelVO = new UserExcelVO();
BeanUtils.copyProperties(userVO, excelVO);
String roleNameList = userVO.getRoleList()
Expand All @@ -274,7 +272,6 @@ public List<UserExcelVO> listUser(UserDTO userDTO) {
excelVO.setPostNameList(postNameList);
return excelVO;
}).collect(Collectors.toList());
return userExcelVOList;
}

/**
Expand Down Expand Up @@ -412,16 +409,16 @@ public R<Boolean> lockUser(String username) {
@Override
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
public R changePassword(UserDTO userDto) {
UserVO userVO = baseMapper.getUserVoById(SecurityUtils.getUser().getId());
if (Objects.isNull(userVO)) {
SysUser sysUser = baseMapper.selectById(SecurityUtils.getUser().getId());
if (Objects.isNull(sysUser)) {
return R.failed("用户不存在");
}

if (StrUtil.isEmpty(userDto.getPassword())) {
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));
}
Expand All @@ -433,7 +430,7 @@ public R changePassword(UserDTO userDto) {

this.update(Wrappers.<SysUser>lambdaUpdate()
.set(SysUser::getPassword, password)
.eq(SysUser::getUserId, userVO.getUserId()));
.eq(SysUser::getUserId, sysUser.getUserId()));
return R.ok();
}

Expand Down

0 comments on commit a352009

Please sign in to comment.