fix 下级部门用户不应该访问到上级树节点

This commit is contained in:
2021-05-27 14:40:41 +08:00
parent a168bee1e3
commit 68e50c1639
2 changed files with 27 additions and 10 deletions

View File

@@ -83,17 +83,18 @@ namespace Ewide.Core.Service
if (dataScopes.Count < 1)
return dataScopeList;
// 此处获取所有的上级节点,用于构造完整树
dataScopes.ForEach(u =>
{
var sysOrg = _sysOrgRep.DetachedEntities.FirstOrDefault(c => c.Id == u);
var parentAndChildIdListWithSelf = sysOrg.Pids.TrimEnd(',').Replace("[", "").Replace("]", "")
.Split(",").ToList();
dataScopeList.AddRange(parentAndChildIdListWithSelf);
// 不需要去查找上级节点
// 添加本级(不知道为什么框架在这里排除了本级)
dataScopeList.Add(u);
});
// 此处获取所有的上级节点,用于构造完整树
//dataScopes.ForEach(u =>
//{
// var sysOrg = _sysOrgRep.DetachedEntities.FirstOrDefault(c => c.Id == u);
// var parentAndChildIdListWithSelf = sysOrg.Pids.TrimEnd(',').Replace("[", "").Replace("]", "")
// .Split(",").ToList();
// dataScopeList.AddRange(parentAndChildIdListWithSelf);
//});
dataScopeList = dataScopes;
}
return dataScopeList.Distinct().ToList();
}

View File

@@ -54,6 +54,22 @@ namespace Ewide.Core
if (_rootParentIds.Contains(u.GetPid()))
results.Add(u);
});
// 在未获取到根节点的情况下, 直接将最上级作为根节点
if (results.Count < 1)
{
var ids = new List<string>();
nodes.ForEach(u => {
ids.Add(u.GetId());
});
nodes.ForEach(u =>
{
if (!ids.Contains(u.GetPid()))
results.Add(u);
});
}
return results;
}