Exemple #1
0
 public async Task <ApiResult <PageList <CommentSubPageResponse> > > QuerySubCommentPageAsync([FromBody] SubCommentPageRequest request)
 {
     return(await _commentService.QuerySubCommentPageAsync(request, null));
 }
Exemple #2
0
        /// <summary>
        /// 查询子评论分页
        /// </summary>
        /// <param name="request"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <ApiResult <PageList <CommentSubPageResponse> > > QuerySubCommentPageAsync(SubCommentPageRequest request, long?userId)
        {
            var response = new ApiResult <PageList <CommentSubPageResponse> >();

            try
            {
                var subComments = await(from c in _commentRepository.TableNotTracking
                                        where c.IsReply == 1 && c.ReplyCommentId == request.CommentId && c.Status == 1
                                        orderby c.CreateTime descending
                                        select new CommentSubPageResponse
                {
                    Id                = c.Id,
                    ArticleId         = c.ArticleId,
                    UserId            = c.UserId,
                    SubReplyUserId    = c.ReplySubUserId,
                    UserName          = c.UserName,
                    SubReplyUserName  = c.ReplySubUserName,
                    SubReplyCommentId = c.ReplySubCommentId,
                    Content           = c.Content,
                    Like              = c.Like,
                    Reply             = c.Reply,
                    CreateTime        = c.CreateTime
                })
                                  .Skip(1)
                                  .ToPageListAsync(request.PageParm.Page, request.PageParm.Size);

                response.Code    = Code.Ok;
                response.Message = "查询成功";
                response.Data    = subComments;
                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError($"查询子评论分页异常;method={nameof(QuerySubCommentPageAsync)};param={request.ToJson()};exception messges={ex.Message}");
                response.Code    = Code.Error;
                response.Message = $"查询子评论分页异常:{ex.Message}";
                return(response);
            }
        }