【8.1.0】【user-org】修改用户角色绑定要清空缓存

pull/60/head
fengshuonan 2024-01-18 15:01:12 +08:00
parent 4b79abc297
commit f3b50f63d4
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.sys.modular.user.service.impl;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.sys.api.SysRoleServiceApi;
@ -42,6 +43,9 @@ public class SysRoleAssignServiceImpl implements SysRoleAssignService {
@Resource
private SysUserRoleService sysUserRoleService;
@Resource(name = "userRoleCache")
private CacheOperatorApi<List<SysUserRole>> userRoleCache;
@Override
public List<NewUserRoleBindResponse> getUserAssignList(Long userId) {
@ -108,6 +112,9 @@ public class SysRoleAssignServiceImpl implements SysRoleAssignService {
else if (pointUserRole != null) {
sysUserRoleService.removeById(pointUserRole.getUserRoleId());
}
// 清空用户绑定的缓存
userRoleCache.remove(String.valueOf(roleControlRequest.getUserId()));
}
@Override
@ -119,6 +126,9 @@ public class SysRoleAssignServiceImpl implements SysRoleAssignService {
// 2. 删除用户在机构下的所有角色信息
this.sysUserRoleService.removeUserOrgRoleLink(deleteRequest.getUserId(), deleteRequest.getOrgId());
// 3. 清空缓存
userRoleCache.remove(String.valueOf(deleteRequest.getUserId()));
}
}