using NPOI.Util;

namespace Tiobon.Core.Api.Controllers;

/// <summary>
/// 试卷(Controller)
/// </summary>
[Route("api/[controller]")]
[ApiController, GlobalActionFilter]
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghre)]
public class Ghre_ExamPaperController : BaseController<IGhre_ExamPaperServices, Ghre_ExamPaper, Ghre_ExamPaperDto, InsertGhre_ExamPaperInput, EditGhre_ExamPaperInput>
{
    public Ghre_ExamPaperController(IGhre_ExamPaperServices service) : base(service)
    {
    }

    #region 基础接口
    #region 查询

    /// <summary>
    /// 根据Id查询数据
    /// </summary>
    /// <param name="Id"></param>
    /// <returns></returns>
    [HttpPost("QueryDefault/{Id}")]
    public async Task<ServiceResult<DefaultGhre_ExamPaperInput>> QueryDefault(long Id)
    {
        return await _service.QueryDefault(Id);
    }

    #region 查询
    /// <summary>
    /// 根据条件查询数据
    /// </summary>
    /// <param name="status">status</param>
    /// <param name="body">条件</param>
    /// <returns></returns>
    [HttpPost, Route("QueryList/{status}")]
    public async Task<ServicePageResult<Ghre_ExamPaperDto>> QueryList(string status, [FromBody] QueryBody body)
    {
        var data = await _service.QueryList(body, status);
        return data;
    }

    #endregion
    #endregion

    #region 新增 

    /// <summary>
    /// 新增 
    /// </summary>
    /// <param name="insert"></param>
    /// <returns></returns>
    [HttpPost("Insert1")]
    public async Task<ServiceResult<long>> Insert1([FromBody] DefaultGhre_ExamPaperPageData insert)
    {
        return await _service.Insert1(insert);
    }
    #endregion

    #region 更新 
    /// <summary>
    /// 更新 
    /// </summary>
    /// <param name="id"></param>
    /// <param name="insert"></param>
    /// <returns></returns>
    [HttpPost("Update1/{id}")]
    public async Task<ServiceResult> Update1(long id, [FromBody] DefaultGhre_ExamPaperPageData insert)
    {
        return await _service.Update1(id, insert);
    }
    [HttpPost("UpdateStatus/{status}")]
    public async Task<ServiceResult> UpdateStatus(string status, [FromBody] long[] ids)
    {
        return await _service.UpdateStatus(ids, status);
    }
    #endregion 

    #region 新增配置数据

    /// <summary>
    /// 新增配置数据
    /// </summary>
    /// <param name="insert"></param>
    /// <returns></returns>
    [HttpPost("InsertConfig")]
    public async Task<ServiceResult<InsertExamPaperConfigInput>> InsertConfig([FromBody] InsertGhre_ExamPaperConfigInput insert)
    {
        return await _service.InsertConfig(insert);
    }
    #endregion

    #endregion


    #region 获取通用列表下拉
    /// <summary>
    /// 获取通用列表下拉
    /// </summary>
    /// <param name="linkId"></param>
    /// <param name="KeyWords"></param>
    /// <returns></returns>
    [HttpPost, Route("GetSelect")]
    public async Task<ServiceResult<CommonSelect>> GetSelectAsync(long? linkId, string KeyWords)
    {
        return await _service.GetSelectAsync(linkId, KeyWords);
    }
    #endregion


    [HttpPost, Route("ExportExcel/{status}")]
    public async Task<ServiceResult<ExcelData>> ExportExcel([FromBody] QueryExport body, string status)
    {
        return await _service.ExportExcel(body, status);
    }

    #region 复制
    [HttpPost, Route("Copy/{id}")]
    public async Task<ServiceResult> Copy(long id) => await _service.Copy(id);
    #endregion
}