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

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

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

@ -1,7 +1,6 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import com.ruoyi.common.satoken.utils.LoginHelper; 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.api.domain.SysUser;
import com.ruoyi.system.service.ISysMenuService; import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.system.service.ISysPermissionService; import com.ruoyi.system.service.ISysPermissionService;
@ -10,7 +9,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -56,17 +54,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
if (LoginHelper.isAdmin(user.getUserId())) { if (LoginHelper.isAdmin(user.getUserId())) {
perms.add("*:*:*"); perms.add("*:*:*");
} else { } else {
List<SysRole> roles = user.getRoles(); perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
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; return perms;
} }

Loading…
Cancel
Save