|
|
@ -119,7 +119,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
throw Oops.Bah("请上传正确数据!");
|
|
|
|
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);
|
|
|
|
await _sysUserDataScopeRep.DeleteAsync(x => x.SysUserId == input.UserId);
|
|
|
|
|
|
|
|
|
|
|
@ -148,17 +148,40 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取权限合集
|
|
|
|
/// 获取权限合集
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="menuid">菜单id</param>
|
|
|
|
/// <param name="menuid">菜单id</param>
|
|
|
|
/// <param name="IsEdit">是否查看编辑权限</param>
|
|
|
|
/// <param name="IsEdit">是否查看编辑权限</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<List<long>> GetDataScopeList(long menuid,bool IsEdit=false)
|
|
|
|
public async Task<List<long>> GetDataScopeList(long menuid, bool IsEdit = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<SysDataUserMenu> list = new List<SysDataUserMenu>();
|
|
|
|
List<SysDataUserMenu> list = new List<SysDataUserMenu>();
|
|
|
|
List<SysUserDataScope> zdylist = new List<SysUserDataScope>();
|
|
|
|
List<SysUserDataScope> zdylist = new List<SysUserDataScope>();
|
|
|
|
|
|
|
|
List<SysOrg> org = new List<SysOrg>();
|
|
|
|
|
|
|
|
List<SysEmp> emp = new List<SysEmp>();
|
|
|
|
List<long> datascope = new List<long>();
|
|
|
|
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))
|
|
|
|
if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPE))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
list = await _sysCache.GetAsync<List<SysDataUserMenu>>(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)
|
|
|
|
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)
|
|
|
|
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);
|
|
|
|
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)
|
|
|
|
else if (_dataScopeType == DataScopeType.DEFINE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var sysorg= zdylist.Where(x => x.SysUserId == UserManager.UserId).Select(x => x.SysOrgId).ToList();
|
|
|
|
var sysorg = zdylist.Where(x => x.SysUserId == UserManager.UserId).Select(x => x.SysOrgId).ToList();
|
|
|
|
List<long> orglist=new List<long>();
|
|
|
|
List<long> orglist = new List<long>();
|
|
|
|
foreach (var orgId in sysorg)
|
|
|
|
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();
|
|
|
|
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;
|
|
|
|
datascope = useridlist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
datascope.Add(UserManager.UserId);
|
|
|
|
datascope.Add(UserManager.UserId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEdit && datascope == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
datascope.Add(UserManager.UserId);
|
|
|
|
|
|
|
|
}
|
|
|
|
return datascope;
|
|
|
|
return datascope;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|