public async Task <IEnumerable <OperationLog> > GetLogList(int pageSize, LogPagingFilteringVM command) { var pg = this.GetPredicateGroup(command); var sort = new List <ISort>(); sort.Add(new Sort { PropertyName = "Id", Ascending = false }); return(await this._logRepository.GetListWithConditionPageList <OperationLog>(command.Page - 1, pageSize, pg, sort)); }
public async Task <ActionResult> Index(LogPagingFilteringVM command) { if (command == null) { command = new LogPagingFilteringVM(); } command.Content = command.Content.RemoveSpace(); LogListVM model = new LogListVM() { Logs = await this.GetLogPageList(command), StartTime = command.StartTime, EndTime = command.EndTime, Content = command.Content }; return(View(model)); }
/// <summary> /// 获取DapperExtensions的PredicateGroup /// </summary> /// <param name="command"></param> /// <returns></returns> private PredicateGroup GetPredicateGroup(LogPagingFilteringVM command) { var pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; if ((command?.StartTime).HasValue) { pg.Predicates.Add(Predicates.Field <OperationLog>(l => l.Ctime, Operator.Ge, command.StartTime)); } if ((command?.EndTime).HasValue) { pg.Predicates.Add(Predicates.Field <OperationLog>(l => l.Ctime, Operator.Lt, command.EndTime.Value.AddDays(1))); } if (!string.IsNullOrWhiteSpace(command?.Content)) { pg.Predicates.Add(Predicates.Field <OperationLog>(l => l.Content, Operator.Like, $"{command.Content.Trim()}%")); } return(pg); }
private async Task <IPagedList <OperationLog> > GetLogPageList(LogPagingFilteringVM command) { var total = await this._logService.GetLogTotal(command); var users = await this._userService.GetList(); var userDic = users.ToDictionary(s => s.Id, v => v.Name); IEnumerable <OperationLog> logs; if (total > 0) { logs = await this._logService.GetLogList(PageSize, command); } else { logs = new List <OperationLog>(); } logs.ToList().ForEach(s => { s.Name = userDic[s.UId]; }); return(new StaticPagedList <OperationLog>(logs, command.Page, PageSize, total)); }
public async Task <int> GetLogTotal(LogPagingFilteringVM command) { var pg = this.GetPredicateGroup(command); return(await this._logRepository.GetTotal <OperationLog>(pg)); }