public async Task <string> QueryPagedAsync([FromQuery] SubjectParam param) { var filter = param.SearchLambda <Subject, SubjectParam>(); var result = await _subjectRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter); foreach (var item in result.Items) { //关联产品数 var subjectProduct = await _subjectRepository.GetSubjectProductsAsync(item.Id); item.ProductCount = subjectProduct.Count(); //评论数 var subjectComment = await _subjectCommentRepository.QueryAsync(c => c.SubjectId == item.Id); item.CommentCount = subjectComment.Count(); } var pageData = new PagedDto <Subject> { Code = 200, Msg = "获取数据成功", Total = result.TotalResults, PageSize = param.PageSize, Data = result.Items.ToList() }; var json = pageData.ToString(); return(json); }
public async Task <ApiRequestResult> QueryAsync() { var result = await _subjectCommentRepository.QueryAsync(); return(ApiRequestResult.Success(result, "")); }