|
|
|
@ -119,7 +119,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
throw Oops.Bah("请上传正确数据!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.childrens!=null&& input.childrens.Count()>0)
|
|
|
|
|
if (input.childrens != null && input.childrens.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
await _sysUserDataScopeRep.DeleteAsync(x => x.SysUserId == input.UserId);
|
|
|
|
|
|
|
|
|
@ -140,7 +140,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
var userdatalist = await _sysUserDataScopeRep.AsQueryable().ToListAsync();
|
|
|
|
|
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPEZDY, userdatalist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (System.Exception)
|
|
|
|
|
{
|
|
|
|
@ -148,17 +148,40 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取权限合集
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="menuid">菜单id</param>
|
|
|
|
|
/// <param name="IsEdit">是否查看编辑权限</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<long>> GetDataScopeList(long menuid,bool IsEdit=false)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取权限合集
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="menuid">菜单id</param>
|
|
|
|
|
/// <param name="IsEdit">是否查看编辑权限</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<long>> GetDataScopeList(long menuid, bool IsEdit = false)
|
|
|
|
|
{
|
|
|
|
|
List<SysDataUserMenu> list = new List<SysDataUserMenu>();
|
|
|
|
|
List<SysUserDataScope> zdylist = new List<SysUserDataScope>();
|
|
|
|
|
List<SysOrg> org = new List<SysOrg>();
|
|
|
|
|
List<SysEmp> emp = new List<SysEmp>();
|
|
|
|
|
List<long> datascope = new List<long>();
|
|
|
|
|
if (_sysCache.Exists(CommonConst.CACHE_KEY_SysOrg))
|
|
|
|
|
{
|
|
|
|
|
org = await _sysCache.GetAsync<List<SysOrg>>(CommonConst.CACHE_KEY_SysOrg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
org = await _sysOrgRep.AsQueryable().ToListAsync();
|
|
|
|
|
_sysCache.Set(CommonConst.CACHE_KEY_SysOrg, org);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_sysCache.Exists(CommonConst.CACHE_KEY_SysEmp))
|
|
|
|
|
{
|
|
|
|
|
emp = await _sysCache.GetAsync<List<SysEmp>>(CommonConst.CACHE_KEY_SysEmp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
emp = await _sysEmpRep.AsQueryable().ToListAsync();
|
|
|
|
|
_sysCache.Set(CommonConst.CACHE_KEY_SysEmp, emp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPE))
|
|
|
|
|
{
|
|
|
|
|
list = await _sysCache.GetAsync<List<SysDataUserMenu>>(CommonConst.CACHE_KEY_USERDATASCOPE);
|
|
|
|
@ -189,33 +212,38 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
}
|
|
|
|
|
else if (_dataScopeType == DataScopeType.DEPT)
|
|
|
|
|
{
|
|
|
|
|
datascope = await _sysEmpRep.AsQueryable().InnerJoin<SysEmp>((d, t) => d.OrgId == t.OrgId && d.Id == UserManager.UserId).Select(d => d.Id).ToListAsync();
|
|
|
|
|
var orgidlist = emp.Where(x => x.Id == UserManager.UserId).Select(x => x.OrgId).ToList();
|
|
|
|
|
datascope = emp.Where(x => orgidlist.Contains(x.OrgId)).Select(x => x.Id).ToList();
|
|
|
|
|
}
|
|
|
|
|
else if (_dataScopeType == DataScopeType.DEPT_WITH_CHILD)
|
|
|
|
|
{
|
|
|
|
|
//获取本部门
|
|
|
|
|
long orgid = _sysEmpRep.Where(x => x.Id == UserManager.UserId).Select(x => x.OrgId).First();
|
|
|
|
|
long orgid = emp.Where(x => x.Id == UserManager.UserId).Select(x => x.OrgId).First();
|
|
|
|
|
//获取下属部门及下属部门
|
|
|
|
|
var orglist = await _sysOrgRep.Where(x => x.TenantId == UserManager.TENANT_ID && x.Pids.Contains(orgid.ToString())).Select(x => x.Id).ToListAsync();
|
|
|
|
|
var orglist = org.Where(x => x.TenantId == UserManager.TENANT_ID && x.Pids.Contains(orgid.ToString())).Select(x => x.Id).ToList();
|
|
|
|
|
orglist.Add(orgid);
|
|
|
|
|
datascope = await _sysEmpRep.Where(x => orglist.Contains(x.OrgId)).Select(x => x.Id).ToListAsync();
|
|
|
|
|
datascope = emp.Where(x => orglist.Contains(x.OrgId)).Select(x => x.Id).ToList();
|
|
|
|
|
}
|
|
|
|
|
else if (_dataScopeType == DataScopeType.DEFINE)
|
|
|
|
|
{
|
|
|
|
|
var sysorg= zdylist.Where(x => x.SysUserId == UserManager.UserId).Select(x => x.SysOrgId).ToList();
|
|
|
|
|
List<long> orglist=new List<long>();
|
|
|
|
|
var sysorg = zdylist.Where(x => x.SysUserId == UserManager.UserId).Select(x => x.SysOrgId).ToList();
|
|
|
|
|
List<long> orglist = new List<long>();
|
|
|
|
|
foreach (var orgId in sysorg)
|
|
|
|
|
{
|
|
|
|
|
var o= _sysOrgRep.AsQueryable().Where(x => x.Pids.Contains(orgId.ToString())).Select(x => x.Id).ToList();
|
|
|
|
|
var o = org.Where(x => x.Pids.Contains(orgId.ToString())).Select(x => x.Id).ToList();
|
|
|
|
|
orglist = orglist.Union(o).ToList();
|
|
|
|
|
}
|
|
|
|
|
var useridlist = _sysEmpRep.AsQueryable().Where(x => orglist.Contains(x.OrgId)).Select(x => x.Id).ToList();
|
|
|
|
|
var useridlist = emp.Where(x => orglist.Contains(x.OrgId)).Select(x => x.Id).ToList();
|
|
|
|
|
datascope = useridlist;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
datascope.Add(UserManager.UserId);
|
|
|
|
|
}
|
|
|
|
|
if (IsEdit && datascope == null)
|
|
|
|
|
{
|
|
|
|
|
datascope.Add(UserManager.UserId);
|
|
|
|
|
}
|
|
|
|
|
return datascope;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|