public async Task <BaseResponse> GetPageGroupsAsync(GroupPageListRequest req) { BasePageResponse <List <GroupViewModel> > br = new BasePageResponse <List <GroupViewModel> >(); var g = _group.Find(a => true); if (!string.IsNullOrWhiteSpace(req.Search)) { g = g.Where(a => a.GroupName.Contains(req.Search) || a.GroupCode.Contains(req.Search) || a.Description.Contains(req.Search)); } int count = g.Count(); string OrderExpression = ""; if (string.IsNullOrEmpty(req.OrderBy)) { OrderExpression = "Id Asc"; //UserQuery = UserQuery.OrderBy(a => a.Id); } else { OrderExpression = string.Format("{0} {1}", req.OrderBy, req.OrderType); } var GroupList = await g.OrderBy(OrderExpression).Skip((req.PageNo - 1) * req.PageSize).Take(req.PageSize).ToListAsync(); var dto = _mapper.Map <List <GroupViewModel> >(GroupList); br.Success = true; br.Message = "获取数据成功"; br.PageSize = req.PageSize; br.CurrentPage = req.PageNo; br.Count = count; br.TotalPage = (int)Math.Ceiling((decimal)count / req.PageSize); br.Data = dto; return(br); }
public async Task <ActionResult <BaseResponse> > GetPageGroup([FromQuery] GroupPageListRequest req) { var ret = await _gs.GetPageGroupsAsync(req); return(ret); }