TopicCommentController.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Common.Page;
  4. using GxPress.Repository.Interface;
  5. using GxPress.Request.App.TopicAnalyze;
  6. using GxPress.Request.App.TopicComment;
  7. using GxPress.Result.App.TopicComment;
  8. using Microsoft.AspNetCore.Authorization;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace GxPress.Api.AppControllers
  11. {
  12. [Route("api/app/topic-comment")]
  13. [ApiController]
  14. [Authorize]
  15. public class TopicCommentController : ControllerBase
  16. {
  17. private readonly ITopicCommentRepository _topicCommentRepository;
  18. private readonly ITopicAnalyzeRepository _topicAnalyzeRepository;
  19. private readonly ILoginContext _loginContext;
  20. public TopicCommentController(ITopicCommentRepository topicCommentRepository, ITopicAnalyzeRepository topicAnalyzeRepository, ILoginContext loginContext)
  21. {
  22. _topicCommentRepository = topicCommentRepository;
  23. _topicAnalyzeRepository = topicAnalyzeRepository;
  24. _loginContext = loginContext;
  25. }
  26. /// <summary>
  27. /// 添加评论
  28. /// </summary>
  29. /// <param name="request"></param>
  30. /// <returns></returns>
  31. [HttpPost("add")]
  32. public async Task<bool> Add([FromBody] TopicCommentInRequest request)
  33. {
  34. request.UserId = _loginContext.AccountId;
  35. return await _topicCommentRepository.TopicCommentInAsync(request) > 0;
  36. }
  37. /// <summary>
  38. /// 分页显示数据 已废弃
  39. /// </summary>
  40. /// <param name="request"></param>
  41. /// <returns></returns>
  42. [HttpPost("list")]
  43. public async Task<PagedList<TopicCommentPageResult>> GetPagedList([FromBody] TopicCommentSearchPageRequest request)
  44. {
  45. return await _topicCommentRepository.GetPagedList(request);
  46. }
  47. /// <summary>
  48. /// 评论点赞 已废弃
  49. /// </summary>
  50. /// <returns></returns>
  51. [HttpPost("laud")]
  52. public async Task<bool> AddArticleAnalyze([FromBody] TopicAnalyzeRequest request)
  53. {
  54. request.UserId = _loginContext.AccountId;
  55. return await _topicAnalyzeRepository.SetTopicAnalyzeAsync(request);
  56. }
  57. }
  58. }