using Microsoft.AspNetCore.Mvc; using GxPress.Service.Interface.Reply; using System.Threading.Tasks; using System.Collections.Generic; using GxPress.Request.Reply; using GxPress.Result.Reply; using GxPress.Auth; using Microsoft.AspNetCore.Authorization; using System.Linq; namespace GxPress.Api.AppControllers { /// /// 回复我的 /// [Route("api/web/reply")] [ApiController] [Authorize] public class WebReplyController : Controller { private readonly IReplyService replyService; private readonly ILoginContext _loginContext; public WebReplyController(IReplyService replyService, ILoginContext _loginContext) { this.replyService = replyService; this._loginContext = _loginContext; } /// /// 获取回复我的笔记或者话题 /// /// /// [HttpPost("list")] public async Task GetReplyNoteOrTopicResults(ReplyRequest request) { request.UserId = _loginContext.AccountId; var result = new ReplyPraiseCountResult(); result.Item = await replyService.GetReplyResults(request); result.PraiseCount = await replyService.GetUReadPraiseCountAsync(request.UserId); return result; } /// /// 获取我收到的赞 /// /// /// [HttpPost("praise")] public async Task> GetPraiseAsync(ReplyRequest request) { request.UserId = _loginContext.AccountId; var result = new List(); result.AddRange(await replyService.GetNotePraiseAsync(request)); result.AddRange(await replyService.GetCommentPraiseAsync(request)); result.AddRange(await replyService.GetNoticePraiseAsync(request)); result.AddRange(await replyService.GetTopicPraiseAsync(request)); result.OrderByDescending(n => n.CreatedDate); await replyService.UpdateUReadPraiseAsync(request.UserId); return result; } } }