public PageData <UserOutputDto> Read(PageRequest request) { Check.NotNull(request, nameof(request)); IFunction function = this.GetExecuteFunction(); Func <User, bool> updateFunc = _filterService.GetDataFilterExpression <User>(null, DataAuthOperation.Update).Compile(); Func <User, bool> deleteFunc = _filterService.GetDataFilterExpression <User>(null, DataAuthOperation.Delete).Compile(); Expression <Func <User, bool> > predicate = _filterService.GetExpression <User>(request.FilterGroup); //查询某一角色的所有用户 //var roleId = request.FilterGroup.Rules.FirstOrDefault(m => m.Field == "RoleId")?.CastTo(0); //if (roleId != 0) //{ // predicate = predicate.And(m => m.UserRoles.Any(n => n.RoleId == roleId)); //} var page = _userManager.Users.ToPage(predicate, request.PageCondition, m => new { D = m, Roles = m.UserRoles.Select(n => n.Role.Name) }).ToPageResult(data => data.Select(m => new UserOutputDto(m.D) { Roles = m.Roles.ToArray(), Updatable = updateFunc(m.D), Deletable = deleteFunc(m.D) }).ToArray()); return(page.ToPageData()); }
public PageData <UserOutputDto2> Read(PageRequest request) { request.FilterGroup.Rules.Add(new FilterRule("IsLocked", false, FilterOperate.Equal)); Expression <Func <User, bool> > predicate = _filterService.GetExpression <User>(request.FilterGroup); var page = _userManager.Users.ToPage <User, UserOutputDto2>(predicate, request.PageCondition); return(page.ToPageData()); }
public PageData <RoleOutputDto2> Read(PageRequest request) { request.FilterGroup.Rules.Add(new FilterRule("IsLocked", false, FilterOperate.Equal)); Expression <Func <Role, bool> > predicate = _filterService.GetExpression <Role>(request.FilterGroup); PageResult <RoleOutputDto2> page = _roleManager.Roles.ToPage <Role, RoleOutputDto2>(predicate, request.PageCondition); return(page.ToPageData()); }
public AjaxResult Read(PageRequest request) { request.AddDefaultSortCondition( new SortCondition("Level"), new SortCondition("Order") ); IFunction function = this.GetExecuteFunction(); Expression<Func<PackOutputDto, bool>> exp = _filterService.GetExpression<PackOutputDto>(request.FilterGroup); IServiceProvider provider = HttpContext.RequestServices; IQueryable<PackOutputDto> query = provider.GetAllPacks().Select(m => new PackOutputDto() { Name = m.GetType().Name, Display = m.GetType().GetDescription(true), Class = m.GetType().FullName, Level = m.Level, Order = m.Order, IsEnabled = m.IsEnabled }).AsQueryable(); var page = _cacheService.ToPageCache(query, exp, request.PageCondition, m => m, function); return new AjaxResult("数据读取成功", AjaxResultType.Success, page.ToPageData()); }
public PageData <EntityRoleOutputDto> Read(PageRequest request) { Expression <Func <EntityRole, bool> > predicate = _filterService.GetExpression <EntityRole>(request.FilterGroup); if (request.PageCondition.SortConditions.Length == 0) { request.PageCondition.SortConditions = new[] { new SortCondition("RoleId"), new SortCondition("EntityId"), new SortCondition("Operation") }; } RoleManager <Role> roleManager = HttpContext.RequestServices.GetService <RoleManager <Role> >(); Func <EntityRole, bool> updateFunc = _filterService.GetDataFilterExpression <EntityRole>(null, DataAuthOperation.Update).Compile(); Func <EntityRole, bool> deleteFunc = _filterService.GetDataFilterExpression <EntityRole>(null, DataAuthOperation.Delete).Compile(); var page = _securityManager.EntityRoles.ToPage(predicate, request.PageCondition, m => new { D = m, RoleName = roleManager.Roles.First(n => n.Id == m.RoleId).Name, EntityName = m.EntityInfo.Name, EntityType = m.EntityInfo.TypeName, }).ToPageResult(data => data.Select(m => new EntityRoleOutputDto(m.D) { RoleName = m.RoleName, EntityName = m.EntityName, EntityType = m.EntityType, Updatable = updateFunc(m.D), Deletable = deleteFunc(m.D) }).ToArray()); return(page.ToPageData()); }
public PageData <FunctionOutputDto2> ReadFunctions(PageRequest request) { if (request.FilterGroup.Rules.Count == 0) { return(new PageData <FunctionOutputDto2>()); } Expression <Func <Module, bool> > moduleExp = _filterService.GetExpression <Module>(request.FilterGroup); int[] moduleIds = _functionAuthManager.Modules.Where(moduleExp).Select(m => m.Id).ToArray(); Guid[] functionIds = _functionAuthManager.ModuleFunctions.Where(m => moduleIds.Contains(m.ModuleId)) .Select(m => m.FunctionId).Distinct().ToArray(); if (functionIds.Length == 0) { return(new PageData <FunctionOutputDto2>()); } if (request.PageCondition.SortConditions.Length == 0) { request.PageCondition.SortConditions = new[] { new SortCondition("Area"), new SortCondition("Controller") }; } var page = _functionAuthManager.Functions.ToPage(m => functionIds.Contains(m.Id), request.PageCondition, m => new FunctionOutputDto2() { Id = m.Id, Name = m.Name, AccessType = m.AccessType, Area = m.Area, Controller = m.Controller }); return(page.ToPageData()); }
public PageData <AuditOperationOutputDto> Read(PageRequest request) { Expression <Func <AuditOperation, bool> > predicate = _filterService.GetExpression <AuditOperation>(request.FilterGroup); request.AddDefaultSortCondition(new SortCondition("CreatedTime", ListSortDirection.Descending)); var page = _auditContract.AuditOperations.ToPage <AuditOperation, AuditOperationOutputDto>(predicate, request.PageCondition); return(page.ToPageData()); }
public AjaxResult Read(PageRequest request) { Check.NotNull(request, nameof(request)); Expression <Func <MenuInfo, bool> > predicate = _filterService.GetExpression <MenuInfo>(request.FilterGroup); var page = _systemsContract.MenuInfos.ToPage <MenuInfo, MenuInfoOutputDto>(predicate, request.PageCondition); return(new AjaxResult("数据读取成功", AjaxResultType.Success, page.ToPageData())); }
public PageData <RoleOutputDto> Read(PageRequest request) { Check.NotNull(request, nameof(request)); IFunction function = this.GetExecuteFunction(); Expression <Func <Role, bool> > predicate = _filterService.GetExpression <Role>(request.FilterGroup); var page = _cacheService.ToPageCache <Role, RoleOutputDto>(_roleManager.Roles, predicate, request.PageCondition, function); return(page.ToPageData()); }
public PageData <EntityInfoOutputDto> Read(PageRequest request) { if (request.PageCondition.SortConditions.Length == 0) { request.PageCondition.SortConditions = new[] { new SortCondition("TypeName") }; } Expression <Func <EntityInfo, bool> > predicate = _filterService.GetExpression <EntityInfo>(request.FilterGroup); var page = _dataAuthManager.EntityInfos.ToPage <EntityInfo, EntityInfoOutputDto>(predicate, request.PageCondition); return(page.ToPageData()); }
public PageData<UserOutputDto> Read(PageRequest request) { Check.NotNull(request, nameof(request)); IFunction function = this.GetExecuteFunction(); Func<User, bool> updateFunc = _filterService.GetDataFilterExpression<User>(null, DataAuthOperation.Update).Compile(); Func<User, bool> deleteFunc = _filterService.GetDataFilterExpression<User>(null, DataAuthOperation.Delete).Compile(); Expression<Func<User, bool>> predicate = _filterService.GetExpression<User>(request.FilterGroup); var page = _cacheService.ToPageCache(_userManager.Users, predicate, request.PageCondition, m => new { D = m, Roles = m.UserRoles.Select(n => n.Role.Name) }, function).ToPageResult(data => data.Select(m => new UserOutputDto(m.D) { Roles = m.Roles.ToArray(), Updatable = updateFunc(m.D), Deletable = deleteFunc(m.D) }).ToArray()); return page.ToPageData(); }
public PageData <UserLoginOutputDto> ReadOAuth2([FromServices] IFilterService filterService, PageRequest request) { int userId = User.Identity.GetUserId <int>(); request.FilterGroup.AddRule("UserId", userId); request.AddDefaultSortCondition(new SortCondition("LoginProvider")); Expression <Func <UserLogin, bool> > exp = filterService.GetExpression <UserLogin>(request.FilterGroup); var page = _identityContract.UserLogins.ToPage <UserLogin, UserLoginOutputDto>(exp, request.PageCondition); return(page.ToPageData()); }
public PageData <UserOutputDto> Read(PageRequest request) { Check.NotNull(request, nameof(request)); IFunction function = this.GetExecuteFunction(); Func <User, bool> updateFunc = _filterService.GetDataFilterExpression <User>(null, DataAuthOperation.Update).Compile(); Func <User, bool> deleteFunc = _filterService.GetDataFilterExpression <User>(null, DataAuthOperation.Delete).Compile(); Expression <Func <User, bool> > predicate = _filterService.GetExpression <User>(request.FilterGroup); var page = _cacheService.ToPageCache(_userManager.Users, predicate, request.PageCondition, m => new { D = m, Roles = _identityContract.UserRoles.Where(n => !n.IsLocked && n.UserId == m.Id) .SelectMany(n => _identityContract.Roles.Where(o => o.Id == n.RoleId).Select(o => o.Name)).Distinct().ToArray() }, function).ToPageResult(data => data.Select(m => new UserOutputDto(m.D) { Roles = m.Roles, Updatable = updateFunc(m.D), Deletable = deleteFunc(m.D) }).ToArray()); return(page.ToPageData()); }
public PageData <FunctionOutputDto> Read(PageRequest request) { IFunction function = this.GetExecuteFunction(); request.AddDefaultSortCondition( new SortCondition("Area"), new SortCondition("Controller"), new SortCondition("IsController", ListSortDirection.Descending)); Expression <Func <Function, bool> > predicate = _filterService.GetExpression <Function>(request.FilterGroup); PageResult <FunctionOutputDto> page = _cacheService.ToPageCache <Function, FunctionOutputDto>(_securityManager.Functions, predicate, request.PageCondition, function); return(page.ToPageData()); }
public PageData <AuditEntityOutputDto> Read(PageRequest request) { Expression <Func <AuditEntity, bool> > predicate = _filterService.GetExpression <AuditEntity>(request.FilterGroup); PageResult <AuditEntityOutputDto> page; //有操作参数,是从操作列表来的 if (request.FilterGroup.Rules.Any(m => m.Field == "OperationId")) { page = _auditContract.AuditEntities.ToPage(predicate, request.PageCondition, m => new AuditEntityOutputDto { Id = m.Id, Name = m.Name, TypeName = m.TypeName, EntityKey = m.EntityKey, OperateType = m.OperateType, Properties = _auditContract.AuditProperties.Where(n => n.AuditEntityId == m.Id).OrderBy(n => n.FieldName != "Id").ThenBy(n => n.FieldName).Select(n => new AuditPropertyOutputDto() { DisplayName = n.DisplayName, FieldName = n.FieldName, OriginalValue = n.OriginalValue, NewValue = n.NewValue, DataType = n.DataType }).ToList() }); return(page.ToPageData()); } request.AddDefaultSortCondition(new SortCondition("Operation.CreatedTime", ListSortDirection.Descending)); page = _auditContract.AuditEntities.ToPage(predicate, request.PageCondition, m => new AuditEntityOutputDto { Id = m.Id, Name = m.Name, TypeName = m.TypeName, EntityKey = m.EntityKey, OperateType = m.OperateType, NickName = m.Operation.NickName, FunctionName = m.Operation.FunctionName, CreatedTime = m.Operation.CreatedTime, Properties = _auditContract.AuditProperties.Where(n => n.AuditEntityId == m.Id).OrderBy(n => n.FieldName != "Id").ThenBy(n => n.FieldName).Select(n => new AuditPropertyOutputDto() { DisplayName = n.DisplayName, FieldName = n.FieldName, OriginalValue = n.OriginalValue, NewValue = n.NewValue, DataType = n.DataType }).ToList() }); return(page.ToPageData()); }
public AjaxResult Read(PageRequest request) { Check.NotNull(request, nameof(request)); Expression <Func <LoginLog, bool> > exp = _filterService.GetExpression <LoginLog>(request.FilterGroup); var page = _identityContract.LoginLogs.ToPage(exp, request.PageCondition, m => new { D = m, User = new { m.User.UserName, m.User.NickName } }).ToPageResult(data => data.Select(m => new LoginLogOutputDto(m.D) { UserName = m.User.UserName, NickName = m.User.NickName }).ToArray()); return(new AjaxResult("ok", AjaxResultType.Success, page.ToPageData())); }
public AjaxResult Read(PageRequest request) { Expression <Func <UserRole, bool> > predicate = _filterService.GetExpression <UserRole>(request.FilterGroup); Func <UserRole, bool> updateFunc = _filterService.GetDataFilterExpression <UserRole>(null, DataAuthOperation.Update).Compile(); Func <UserRole, bool> deleteFunc = _filterService.GetDataFilterExpression <UserRole>(null, DataAuthOperation.Delete).Compile(); PageResult <UserRoleOutputDto> page = _identityContract.UserRoles.ToPage(predicate, request.PageCondition, m => new { D = m, UserName = m.User.UserName, RoleName = m.Role.Name, }).ToPageResult(data => data.Select(m => new UserRoleOutputDto(m.D) { UserName = m.UserName, RoleName = m.RoleName, Updatable = updateFunc(m.D), Deletable = deleteFunc(m.D) }).ToArray()); return(new AjaxResult("数据读取成功", AjaxResultType.Success, page.ToPageData())); }
public PageData <UserRoleOutputDto> Read(PageRequest request) { Expression <Func <UserRole, bool> > predicate = _filterService.GetExpression <UserRole>(request.FilterGroup); Func <UserRole, bool> updateFunc = _filterService.GetDataFilterExpression <UserRole>(null, DataAuthOperation.Update).Compile(); Func <UserRole, bool> deleteFunc = _filterService.GetDataFilterExpression <UserRole>(null, DataAuthOperation.Delete).Compile(); PageResult <UserRoleOutputDto> page = _identityContract.UserRoles.ToPage(predicate, request.PageCondition, m => new { D = m, UserName = _identityContract.Users.Where(n => n.Id == m.UserId).Select(n => n.UserName).FirstOrDefault(), RoleName = _identityContract.Roles.Where(n => n.Id == m.RoleId).Select(n => n.Name).FirstOrDefault() }).ToPageResult(data => data.Select(m => new UserRoleOutputDto(m.D) { UserName = m.UserName, RoleName = m.RoleName, Updatable = updateFunc(m.D), Deletable = deleteFunc(m.D) }).ToArray()); return(page.ToPageData()); }
public PageData <PackOutputDto> Read(PageRequest request) { request.AddDefaultSortCondition( new SortCondition("Level"), new SortCondition("Order") ); IFunction function = this.GetExecuteFunction(); Expression <Func <OsharpPack, bool> > exp = _filterService.GetExpression <OsharpPack>(request.FilterGroup); IServiceProvider provider = HttpContext.RequestServices; return(_cacheService.ToPageCache(provider.GetAllPacks().AsQueryable(), exp, request.PageCondition, m => new PackOutputDto() { Name = m.GetType().Name, Display = m.GetType().GetDescription(false), Class = m.GetType().FullName, Level = m.Level, Order = m.Order, IsEnabled = m.IsEnabled }, function).ToPageData()); }