using System.Threading.Tasks;
using GxPress.Common.Page;
using GxPress.Entity;
using GxPress.Repository.Interface;
using GxPress.Request.Feedback;
using GxPress.Result.Feedback;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace GxPress.Api.AdminControllers
{
    /// <summary>
    /// 意见反馈
    /// </summary>
    [Route("api/admin/Feedback")]
    [ApiController]
    [Authorize]
    public class AdminFeedbackController : ControllerBase
    {
        private readonly ILogger<AdminAppVersionController> _logger;
        private readonly IFeedbackRepository _feedbackRepository;

        public AdminFeedbackController(ILogger<AdminAppVersionController> logger, IFeedbackRepository feedbackRepository)
        {
            _logger = logger;
            _feedbackRepository = feedbackRepository;
        }

        /// <summary>
        /// 查询分页数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("page")]
        public async Task<PagedList<FeedbackPageResult>> GetPageList([FromBody] FeedbackPageRequest request)
        {
            return await _feedbackRepository.GetPagedList(request);
        }
        /// <summary>
        /// 删除意见反馈
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("{id}")]
        public async Task<bool> Delete(int id)
        {
            return await _feedbackRepository.DeleteAsync(id);
        }
    }
}