【8.3.3】【sys】【cache】更新用户的缓存操作

dev-8.3.3
stylefeng 2025-01-14 16:19:20 +08:00
parent 17fd7544b5
commit 4af284608b
1 changed files with 10 additions and 2 deletions

View File

@ -148,6 +148,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 删除用户的业务操作
this.baseRemoveUser(CollectionUtil.set(false, sysUser.getUserId()));
// 发布更新缓存事件,清空用户名称缓存
BusinessEventPublisher.publishEvent(UPDATE_USER_NAME_EVENT, sysUser.getUserId());
// 记录日志
BusinessLogUtil.setLogTitle("删除用户,用户账号:" + sysUser.getAccount());
BusinessLogUtil.addContent("用户账号:", sysUser.getAccount());
@ -171,6 +174,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 删除用户的业务操作
this.baseRemoveUser(userIdList);
// 发布更新缓存事件,清空用户名称缓存
for (Long userId : userIdList) {
BusinessEventPublisher.publishEvent(UPDATE_USER_NAME_EVENT, userId.toString());
}
// 记录日志
BusinessLogUtil.setLogTitle("批量删除用户");
BusinessLogUtil.addContent("用户id集合为\n", userIdList);
@ -500,12 +508,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
SysUser sysUser = this.getOne(sysUserLambdaQueryWrapper);
if (sysUser == null) {
// 查询结果记录到缓存
userNameCache.put(userId.toString(), "");
userNameCache.put(userId.toString(), "", SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
return "";
}
// 查询结果记录到缓存
userNameCache.put(userId.toString(), sysUser.getRealName());
userNameCache.put(userId.toString(), sysUser.getRealName(), SysConstants.DEFAULT_SYS_CACHE_TIMEOUT_SECONDS);
return sysUser.getRealName();
}