public async Task <ResultDto <CommentDto> > GetPageDataAsync(CommentQueryModel qModel) { var result = new ResultDto <CommentDto>(); var query = _testDB.Comment.AsNoTracking().Where(x => !x.IsDelete); query = qModel.State.HasValue ? query.Where(x => x.Status == qModel.State) : query; var queryData = query.Select(x => new CommentDto() { Id = x.Id, ArticleId = x.ArticleId, Content = x.Content, Status = x.Status, ParentId = x.ParentId.HasValue ? x.ParentId.Value : 0, Creator = x.Creator, CreateTime = x.CreateTime }); queryData = queryData.OrderBy(o => o.CreateTime); queryData = queryData.Skip((qModel.PageIndex - 1) * qModel.PageSize).Take(qModel.PageSize); result.ActionResult = true; result.Message = "Success"; result.List = await queryData.ToListAsync(); return(result); }
public async Task <JsonResult> GetPageAsync(CommentQueryModel qModel) { var id = UserId; var name = UserName; var res = await _commentSvc.GetPageDataAsync(qModel); return(Json(res)); }
public async Task <IResultModel> Query(CommentQueryModel model) { var result = new QueryResultModel <CommentEntity> { Rows = await _repository.Query(model), Total = model.TotalCount }; return(ResultModel.Success(result)); }
public async Task <IList <CommentEntity> > Query(CommentQueryModel model) { var paging = model.Paging(); var query = Db.Find(); var joinQuery = query.LeftJoin <TopicEntity>((t1, t2) => t1.TopicId == t2.Id) .LeftJoin <UserEntity>((t1, t2, t3) => t1.To == t3.Id) .LeftJoin <UserEntity>((t1, t2, t3, t4) => t2.UserId == t4.Id); joinQuery.WhereNotNull(model.TopicId, (t1, t2, t3, t4) => t1.TopicId == model.TopicId); joinQuery.WhereNotNull(model.UserId, (t1, t2, t3, t4) => t1.UserId == model.UserId); joinQuery.WhereNotNull(model.To, (t1, t2, t3, t4) => t1.To == model.To); if (!paging.OrderBy.Any()) { joinQuery.OrderByDescending((t1, t2, t3, t4) => t1.Id); } joinQuery.Select((t1, t2, t3, t4) => new { t1, TopicTitle = t2.Title, ToNickName = t3.NickName, ToAvatar = t3.Avatar, ToSex = t3.Sex, t4.NickName, t4.Avatar, t4.Sex }); var result = await joinQuery.PaginationAsync(paging); model.TotalCount = paging.TotalCount; return(result); }
public Task <IResultModel> Query([FromQuery] CommentQueryModel model) { return(_service.Query(model)); }
public async Task <JsonResult> GetPageAsync(CommentQueryModel qModel) { var result = await _commentSvc.GetPageDataAsync(qModel); return(Json(result)); }