public ActionResult <ReplyInfoViewModelResponse> GetRepliesByPostId(int postId, int currPage, int pageSize) { try { var headerStr = Request.Headers["Authorization"]; var jwtHelper = new JWTHelper(_configuration); var user = new UserInfo { UserId = jwtHelper.GetJWTUserData(headerStr) }; // 获取一级回复 var replyInfo = new ReplyInfo { ParentReplyId = 0, PostInfo = new PostInfo { PostId = postId } }; var result = _replyService.GetReplies(replyInfo, user, currPage, pageSize); var replyInfoViewModelRes = new ReplyInfoViewModelResponse(); foreach (var r in result) { r.ReplyInfoViewModels = _replyService.GetInnerReplies(new ReplyInfo { ReplyId = r.ReplyId }, user, 1, pageSize); } replyInfoViewModelRes.ReplyInfoViewModels = result; replyInfoViewModelRes.ReplyTotalCount = _replyService.GetParentReplyCount(replyInfo); return(replyInfoViewModelRes); } catch (Exception ex) { Console.WriteLine(ex); throw ex; } }