修改个人信息后,清除缓存的问题,应该是修改登录用户的缓存,目前清除的是越权账号的缓存

This commit is contained in:
xumin 2022-06-23 15:16:02 +08:00
parent 8eb380ba26
commit 64652146af
2 changed files with 4 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.datatype.jsr310.ser.YearSerializer;
import com.pig4cloud.pig.admin.api.dto.UserDTO; import com.pig4cloud.pig.admin.api.dto.UserDTO;
import com.pig4cloud.pig.admin.api.dto.UserInfo; import com.pig4cloud.pig.admin.api.dto.UserInfo;
import com.pig4cloud.pig.admin.api.entity.SysUser; import com.pig4cloud.pig.admin.api.entity.SysUser;
@ -186,6 +187,8 @@ public class UserController {
@SysLog("修改个人信息") @SysLog("修改个人信息")
@PutMapping("/edit") @PutMapping("/edit")
public R<Boolean> updateUserInfo(@Valid @RequestBody UserDTO userDto) { public R<Boolean> updateUserInfo(@Valid @RequestBody UserDTO userDto) {
String username = SecurityUtils.getUser().getUsername();
userDto.setUsername(username);
return R.ok(userService.updateUserInfo(userDto)); return R.ok(userService.updateUserInfo(userDto));
} }

View File

@ -173,8 +173,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override @Override
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username") @CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
public Boolean updateUserInfo(UserDTO userDto) { public Boolean updateUserInfo(UserDTO userDto) {
String username = SecurityUtils.getUser().getUsername(); UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
UserVO userVO = baseMapper.getUserVoByUsername(username);
Assert.isTrue(ENCODER.matches(userDto.getPassword(), userVO.getPassword()), Assert.isTrue(ENCODER.matches(userDto.getPassword(), userVO.getPassword()),
MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR)); MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR));