using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using New_College.IServices;
using New_College.Model;
using New_College.Model.ViewModels;

namespace New_College.Api.Controllers.Back
{
    [Route("api/back/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ExaminationPolicyController : ControllerBase
    {
        private readonly IV_ExaminationPolicyServices iV_ExaminationPolicyServices;
        public ExaminationPolicyController(IV_ExaminationPolicyServices IV_ExaminationPolicyServices)
        {
            iV_ExaminationPolicyServices = IV_ExaminationPolicyServices;
        }

        /// <summary>
        /// 获取分页
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<PageModel<ExaminationPolicyResult>>> GetExaminationPolicyByPage([FromQuery] ExaminationPolicySearchQuery query)
        {
            return await iV_ExaminationPolicyServices.GetExaminationPolicyByPage(query);
        }

        /// <summary>
        /// 获取单个
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<ExaminationPolicyOneResult>> GetExaminationPolicyOne([FromQuery] IdQuery query)
        {
            return await iV_ExaminationPolicyServices.GetExaminationPolicyOne(query);
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<MessageModel<bool>> AddExaminationPolicy([FromBody] ExaminationPolicyQuery query)
        {
            return await iV_ExaminationPolicyServices.AddExaminationPolicy(query);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<MessageModel<bool>> UpdateExaminationPolicy(ExaminationPolicyQuery query)
        {
            return await iV_ExaminationPolicyServices.UpdateExaminationPolicy(query);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<MessageModel<bool>> DeleteExaminationPolicy([FromBody] IdQuery query)
        {
            return await iV_ExaminationPolicyServices.DeleteExaminationPolicy(query);
        }
    }
}
