update:删除原先获取角色权限得代码

This commit is contained in:
2021-07-01 15:44:17 +08:00
parent 9d04976276
commit 5a8c63b096
15 changed files with 26 additions and 191 deletions

View File

@@ -12,7 +12,6 @@ namespace Ewide.Core.Service
Task<dynamic> GetRoleDropDown();
Task<SysRole> GetRoleInfo([FromQuery] QueryRoleInput input);
Task<dynamic> GetRoleList([FromQuery] RoleInput input);
Task<List<string>> GetUserDataScopeIdList(List<string> roleIdList, string orgId);
Task<List<RoleOutput>> GetUserRoleList(string userId);
Task GrantData(GrantRoleDataInput input);
Task GrantMenu(GrantRoleMenuInput input);

View File

@@ -218,7 +218,7 @@ namespace Ewide.Core.Service
//如果授权的角色数据范围类型为自定义,则要判断授权的数据范围是否在自己的数据范围内
if ((int)DataScopeType.DEFINE == dataScopeType)
{
var dataScopes = await _sysOrgService.GetUserDataScopeIdList();
var dataScopes = await _userManager.GetUserAllDataScopeList();
var grantOrgIdList = input.GrantOrgIdList; //要授权的数据范围列表
if (grantOrgIdList.Count > 0)
{
@@ -233,46 +233,6 @@ namespace Ewide.Core.Service
await _sysRoleDataScopeService.GrantDataScope(input);
}
/// <summary>
/// 根据角色Id集合获取数据范围Id集合
/// </summary>
/// <param name="roleIdList"></param>
/// <param name="orgId"></param>
/// <returns></returns>
[NonAction]
public async Task<List<string>> GetUserDataScopeIdList(List<string> roleIdList, string orgId)
{
// 定义角色中最大数据范围的类型目前按最大范围策略来如果你同时拥有ALL和SELF的权限最后按ALL返回
int strongerDataScopeType = (int)DataScopeType.SELF;
int strongerAreaType = (int)DataScopeType.SELF;
var customDataScopeRoleIdList = new List<string>();
if (roleIdList != null && roleIdList.Count > 0)
{
var roles = await _sysRoleRep.DetachedEntities.Where(u => roleIdList.Contains(u.Id)).ToListAsync();
roles.ForEach(u =>
{
if (u.DataScopeType == (int)DataScopeType.DEFINE)
customDataScopeRoleIdList.Add(u.Id);
if ((u.DataScopeType == (int)DataScopeType.AREA || u.DataScopeType == (int)DataScopeType.AREA_WITH_CHILD) && strongerAreaType < u.DataScopeType)
{
strongerAreaType = u.DataScopeType;
}
else if (u.DataScopeType <= strongerDataScopeType)
strongerDataScopeType = u.DataScopeType;
});
}
// 自定义数据范围的角色对应的数据范围
var roleDataScopeIdList = await _sysRoleDataScopeService.GetRoleDataScopeIdList(customDataScopeRoleIdList);
// 角色中拥有最大数据范围类型的数据范围
var dataScopeIdList = await _sysOrgService.GetDataScopeListByDataScopeType(strongerDataScopeType, orgId);
//角色区域数据范围
var areaOrgIdList = await _sysOrgService.GetAreaDataScopeIdList(strongerAreaType, orgId);
return roleDataScopeIdList.Concat(dataScopeIdList).Concat(areaOrgIdList).Distinct().ToList(); //并集
}
/// <summary>
/// 根据角色Id获取角色名称
/// </summary>