12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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
- {
- /// <summary>
- /// 回复我的
- /// </summary>
- [Route("api/app/reply")]
- [ApiController]
- [Authorize]
- public class ReplyController : Controller
- {
- private readonly IReplyService replyService;
- private readonly ILoginContext _loginContext;
- public ReplyController(IReplyService replyService, ILoginContext _loginContext)
- {
- this.replyService = replyService;
- this._loginContext = _loginContext;
- }
- /// <summary>
- /// 获取回复我的笔记或者话题
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("list")]
- public async Task<ReplyPraiseCountResult> 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;
- }
- /// <summary>
- /// 获取我收到的赞
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("praise")]
- public async Task<IEnumerable<ReplyResult>> GetPraiseAsync(ReplyRequest request)
- {
- request.UserId = _loginContext.AccountId;
- var result = new List<ReplyResult>();
- result.AddRange(await replyService.GetNotePraiseAsync(request));
- result.AddRange(await replyService.GetCommentPraiseAsync(request));
- result.AddRange(await replyService.GetNoticePraiseAsync(request));
- result.AddRange(await replyService.GetTopicPraiseAsync(request));
- var dd = result.OrderByDescending(n => n.CreatedDate);
- await replyService.UpdateUReadPraiseAsync(request.UserId);
- return dd;
- }
- }
- }
|