mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	新建的用户未分配角色时,操作自己信息回报错的问题
This commit is contained in:
		@@ -458,13 +458,16 @@ public class PermissionServiceImpl implements PermissionService {
 | 
			
		||||
    @DataPermission(enable = false) // 关闭数据权限,不然就会出现递归获取数据权限的问题
 | 
			
		||||
    @TenantIgnore // 忽略多租户的自动过滤。如果不忽略,会导致添加租户时,因为切换租户,导致获取不到 User。即使忽略,本身该方法不存在跨租户的操作,不会存在问题。
 | 
			
		||||
    public DeptDataPermissionRespDTO getDeptDataPermission(Long userId) {
 | 
			
		||||
        DeptDataPermissionRespDTO result = new DeptDataPermissionRespDTO();
 | 
			
		||||
        // 获得用户的角色
 | 
			
		||||
        Set<Long> roleIds = getUserRoleIdsFromCache(userId, singleton(CommonStatusEnum.ENABLE.getStatus()));
 | 
			
		||||
        // 如果角色为空,则只能查看自己
 | 
			
		||||
        DeptDataPermissionRespDTO result = new DeptDataPermissionRespDTO();
 | 
			
		||||
        if (CollUtil.isEmpty(roleIds)) {
 | 
			
		||||
            result.setSelf(true);
 | 
			
		||||
            return result;
 | 
			
		||||
        }
 | 
			
		||||
        List<RoleDO> roles = roleService.getRolesFromCache(roleIds);
 | 
			
		||||
 | 
			
		||||
        // 获得用户的部门编号的缓存,通过 Guava 的 Suppliers 惰性求值,即有且仅有第一次发起 DB 的查询
 | 
			
		||||
        Supplier<Long> userDeptIdCache = Suppliers.memoize(() -> userService.getUser(userId).getDeptId());
 | 
			
		||||
        // 遍历每个角色,计算
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user