update 优化 获取菜单数据权限接口 删除无用角色属性与逻辑

2.X
疯狂的狮子li 2 years ago
parent a537674cfe
commit 630264f2f4

@ -115,12 +115,6 @@ public class SysRole extends BaseEntity {
@TableField(exist = false)
private Long[] deptIds;
/**
*
*/
@TableField(exist = false)
private Set<String> permissions;
public SysRole(Long roleId) {
this.roleId = roleId;
}

@ -1,7 +1,6 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.system.api.domain.SysRole;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.system.service.ISysPermissionService;
@ -10,7 +9,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@ -55,19 +53,9 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
// 管理员拥有所有权限
if (LoginHelper.isAdmin(user.getUserId())) {
perms.add("*:*:*");
} else {
List<SysRole> roles = user.getRoles();
if (!roles.isEmpty() && roles.size() > 1) {
// 多角色设置permissions属性以便数据权限匹配权限
for (SysRole role : roles) {
Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
role.setPermissions(rolePerms);
perms.addAll(rolePerms);
}
} else {
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
}
}
return perms;
}
}

Loading…
Cancel
Save