|
|
|
@ -27,7 +27,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
private readonly SqlSugarRepository<SysOrg> _sysOrgRep; // 组织机构表仓储
|
|
|
|
|
private readonly SqlSugarRepository<SysEmp> _sysEmpRep; // 员工表仓储
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _sysuser; // 员工表
|
|
|
|
|
private readonly SqlSugarRepository<SysUserDataScope> _sysUserDataScopeRep; // 用户数据范围表仓储
|
|
|
|
|
private readonly SqlSugarRepository<SysUserDataScope> _sysUserDataScopeRep; // 自定义范围
|
|
|
|
|
public SysDataUserMenuService(SqlSugarRepository<SysDataUserMenu> rep, ISysCacheService sysCache, SqlSugarRepository<SysUser> sysuser, SqlSugarRepository<SysUserDataScope> sysUserDataScopeRep, SqlSugarRepository<SysEmp> sysEmpRep, SqlSugarRepository<SysOrg> sysOrgRep)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
@ -157,6 +157,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
public async Task<List<long>> GetDataScopeList(long menuid,bool IsEdit=false)
|
|
|
|
|
{
|
|
|
|
|
List<SysDataUserMenu> list = new List<SysDataUserMenu>();
|
|
|
|
|
List<SysUserDataScope> zdylist = new List<SysUserDataScope>();
|
|
|
|
|
List<long> datascope = new List<long>();
|
|
|
|
|
if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPE))
|
|
|
|
|
{
|
|
|
|
@ -167,6 +168,16 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
list = await _rep.AsQueryable().ToListAsync();
|
|
|
|
|
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, list);
|
|
|
|
|
}
|
|
|
|
|
if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPEZDY))
|
|
|
|
|
{
|
|
|
|
|
zdylist = await _sysCache.GetAsync<List<SysUserDataScope>>(CommonConst.CACHE_KEY_USERDATASCOPEZDY);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
zdylist = await _sysUserDataScopeRep.AsQueryable().ToListAsync();
|
|
|
|
|
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPEZDY, list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataScopeType _dataScopeType = list.Where(x => x.SysMenuId == menuid && x.SysUserId == UserManager.UserId).WhereIF(IsEdit == true, x => x.IsEdit == true).Select(x => x.DataScopeType).FirstOrDefault();
|
|
|
|
|
if (_dataScopeType == DataScopeType.ALL)
|
|
|
|
|
{
|
|
|
|
@ -191,8 +202,15 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
|
|
|
|
|
}
|
|
|
|
|
else if (_dataScopeType == DataScopeType.DEFINE)
|
|
|
|
|
{
|
|
|
|
|
datascope = await _sysUserDataScopeRep.AsQueryable().InnerJoin<SysEmp>((d, t) => d.SysOrgId == t.OrgId && d.SysMenuId == menuid && d.SysUserId == UserManager.UserId)
|
|
|
|
|
.WhereIF(IsEdit == true, (d, t) => d.IsEdit == true).Select((d, t) => t.Id).ToListAsync();
|
|
|
|
|
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();
|
|
|
|
|
orglist = orglist.Union(o).ToList();
|
|
|
|
|
}
|
|
|
|
|
var useridlist = _sysEmpRep.AsQueryable().Where(x => orglist.Contains(x.OrgId)).Select(x => x.Id).ToList();
|
|
|
|
|
datascope = useridlist;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|