using System.Threading.Tasks;
using GxPress.Common.Page;
using GxPress.Repository.Interface;
using GxPress.Request.Comment;
using GxPress.Result.Comment;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace GxPress.Api.AdminControllers
{
    /// <summary>
    /// 文章评论 通知评论
    /// </summary>
    [Route("api/admin/comment")]
    [ApiController]
    public class AdminCommentController : ControllerBase
    {
        private readonly ICommentRepository _commentRepository;
        public AdminCommentController(ICommentRepository commentRepository)
        {
            _commentRepository = commentRepository;
        }

       
        /// <summary>
        /// 分页显示数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("page")]
        public async Task<PagedList<CommentPageResult>> GetPagedList([FromBody] CommentSearchPageRequest request)
        {
            return await _commentRepository.GetPagedList(request);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete("delete")]
        [AllowAnonymous]
        public async Task<bool> Delete([FromBody] CommentDeleteRequest request)
        {
            return await _commentRepository.DeleteCommentAsync(request);
        }
    }
}