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;
}
///
/// 添加评论
///
///
///
[HttpPost("add")]
public async Task Add([FromBody] TopicCommentInRequest request)
{
request.UserId = _loginContext.AccountId;
return await _topicCommentRepository.TopicCommentInAsync(request) > 0;
}
///
/// 分页显示数据 已废弃
///
///
///
[HttpPost("list")]
public async Task> GetPagedList([FromBody] TopicCommentSearchPageRequest request)
{
return await _topicCommentRepository.GetPagedList(request);
}
///
/// 评论点赞 已废弃
///
///
[HttpPost("laud")]
public async Task AddArticleAnalyze([FromBody] TopicAnalyzeRequest request)
{
request.UserId = _loginContext.AccountId;
return await _topicAnalyzeRepository.SetTopicAnalyzeAsync(request);
}
}
}