/// <summary> /// 获取用户可见的所有资源(除菜单外) /// </summary> /// <returns></returns> public async Task <IEnumerable <SysMenuDto> > GetCurrentUserResourcesDtoAsync() { //IEnumerable<SysMenuTreeItemDto> sysMenuTreeItems = null;// int currentAdminId = _adminWorkContextProvider.GetAdminWorkContext().AdminUserId; SenparcEntitiesBase db = _serviceProvider.GetService <SenparcEntitiesBase>(); List <SysMenuDto> sysMenuDtos = await getUserPermissions(currentAdminId).Where(_ => _.MenuType > MenuType.菜单).OrderByDescending(_ => _.Sort).ToListAsync(); return(sysMenuDtos);// _sysMenuService.GetSysMenuTreesMainRecursive(sysMenuDtos); }
/// <summary> /// 获取用户得权限(包括按钮) /// </summary> /// <param name="currentAdminUserId"></param> /// <returns></returns> private IQueryable <SysMenuDto> getUserPermissions(int currentAdminUserId) { IConfigurationProvider autoMapConfigurationProvider = _serviceProvider.GetService <IMapper>().ConfigurationProvider; SenparcEntitiesBase db = _serviceProvider.GetService <SenparcEntitiesBase>(); IQueryable <string> roleIds = from roleAdmin in db.SysRoleAdminUserInfos where roleAdmin.AccountId == currentAdminUserId && db.SysRoles.Any(role => role.Id == roleAdmin.RoleId && role.Enabled) select roleAdmin.RoleId;// db.SysRoleAdminUserInfos.Where(_ => _.AccountId == currentAdminUserId).Select(_ => _.RoleId); IQueryable <string> menuIds = from permission in db.SysPermission where roleIds.Any(_ => _ == permission.RoleId) select permission.PermissionId; return(db.SysMenus.Where(_ => _.Visible && menuIds.Contains(_.Id)).ProjectTo <SysMenuDto>(autoMapConfigurationProvider)); }
public SysButtonRespository(ISqlBaseFinanceData db) : base(db) { _senparcEntities = db.BaseDataContext as SenparcEntitiesBase; }
public SysMenuService(ClientRepositoryBase <SysMenu> repo, IServiceProvider serviceProvider) : base(repo, serviceProvider) { _sysButtonService = _serviceProvider.GetService <SysButtonService>(); _distributedCache = _serviceProvider.GetService <IDistributedCache>(); _senparcEntities = _serviceProvider.GetService <SenparcEntitiesBase>(); }