using System.Threading.Tasks; using GxPress.Auth; using GxPress.Common.Page; using GxPress.Repository.Interface; using GxPress.Request.App.TopicAnalyze; using GxPress.Request.App.TopicComment; using GxPress.Result.App.TopicComment; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AppControllers { [Route("api/app/topic-comment")] [ApiController] [Authorize] public class TopicCommentController : ControllerBase { private readonly ITopicCommentRepository _topicCommentRepository; private readonly ITopicAnalyzeRepository _topicAnalyzeRepository; private readonly ILoginContext _loginContext; public TopicCommentController(ITopicCommentRepository topicCommentRepository, ITopicAnalyzeRepository topicAnalyzeRepository, ILoginContext loginContext) { _topicCommentRepository = topicCommentRepository; _topicAnalyzeRepository = topicAnalyzeRepository; _loginContext = loginContext; } /// <summary> /// 添加评论 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("add")] public async Task<bool> Add([FromBody] TopicCommentInRequest request) { request.UserId = _loginContext.AccountId; return await _topicCommentRepository.TopicCommentInAsync(request) > 0; } /// <summary> /// 分页显示数据 已废弃 /// </summary> /// <param name="request"></param> /// <returns></returns> [HttpPost("list")] public async Task<PagedList<TopicCommentPageResult>> GetPagedList([FromBody] TopicCommentSearchPageRequest request) { return await _topicCommentRepository.GetPagedList(request); } /// <summary> /// 评论点赞 已废弃 /// </summary> /// <returns></returns> [HttpPost("laud")] public async Task<bool> AddArticleAnalyze([FromBody] TopicAnalyzeRequest request) { request.UserId = _loginContext.AccountId; return await _topicAnalyzeRepository.SetTopicAnalyzeAsync(request); } } }