using Exam.Application.Interface.Exam;
using Exam.Infrastructure.Data.Entity;
using Hotline.Application.Exam.Constants.ApiRoutes;
using Hotline.Application.Exam.Interface.ExamManages;
using Hotline.Share.Dtos.ExamManages;
using Hotline.Share.Requests.Exam;
using Hotline.Share.ViewResponses.Exam;
using Microsoft.AspNetCore.Mvc;

namespace Hotline.Api.Controllers.Exam
{
    public class ExamTagController : BaseController
    {
        private readonly IExamTagService _examTagService;
        public ExamTagController(IExamTagService examTagService)
        {
            _examTagService = examTagService;
        }

        /// <summary>
        /// 新增考试标签
        /// </summary>
        /// <param name="examTagDto"></param>
        /// <returns></returns>
        [HttpPost(ExamTagApiRoute.Add)]
        public async Task Add([FromBody] AddExamTagDto examTagDto)
        {
            await _examTagService.AddAsync(examTagDto, HttpContext.RequestAborted);
        }

        /// <summary>
        /// 修改考试标签
        /// </summary>
        /// <param name="examTagDto"></param>
        /// <returns></returns>
        [HttpPut(ExamTagApiRoute.Update)]
        public async Task Update([FromBody] UpdateExamTagDto examTagDto)
        {
            await _examTagService.UpdateAsync(examTagDto, HttpContext.RequestAborted);
        }

        /// <summary>
        /// 删除考试标签
        /// </summary>
        /// <param name="entityQueryRequest"></param>
        /// <returns></returns>
        [HttpDelete(ExamTagApiRoute.Delete)]

        public async Task Delete(EntityQueryRequest entityQueryRequest)
        {
            await _examTagService.DeleteAsync(entityQueryRequest, HttpContext.RequestAborted);
        }

        /// <summary>
        /// 获取树形列表
        /// </summary>
        /// <returns></returns>
        [HttpPost(ExamTagApiRoute.GetTreeList)]
        public async Task<List<ExamTagViewResponse>> GetTreeList([FromBody] ExamTagRequest examTagRequest)
        {
            var examTags = await _examTagService.GetTreeAsync(examTagRequest);

            return examTags;
        }

        /// <summary>
        /// 获取课件分类
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet(ExamTagApiRoute.Get)]
        public async Task<ExamTagDto> Get(string id)
        {
            var examTagDto = await _examTagService.GetAsync(new EntityQueryRequest
            {
                Id = id
            });

            return examTagDto;
        }
    }
}
