using Tiobon.Core.Model.ViewModels.Extend;

namespace Tiobon.Core.Api.Controllers;

/// <summary>
/// 问卷调查(Controller)
/// </summary>
[Route("api/[controller]")]
[ApiController, GlobalActionFilter]
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghre)]
public class Ghre_SurveyController : BaseController<IGhre_SurveyServices, Ghre_Survey, Ghre_SurveyDto, InsertGhre_SurveyInput, EditGhre_SurveyInput>
{
    public Ghre_SurveyController(IGhre_SurveyServices service) : base(service)
    {
    }

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

    }
    #endregion

    #region 状态修改 
    [HttpPost("UpdateStatus/{status}")]
    public async Task<ServiceResult> UpdateStatus(string status, [FromBody] InsertGhre_SurveyInput input)
    {
        return await _service.UpdateStatus(input, status);
    }
    #endregion 

    #region 新增 
    [HttpPost("Insert/{status}")]
    public async Task<ServiceResult<long>> InsertByStatus([FromBody] InsertGhre_SurveyInput insertModel, string status)
    {
        return await _service.InsertByStatus(insertModel, status);
    }
    #endregion 

    #region 插入 
    /// <summary>
    /// 插入
    /// </summary> 
    /// <param name="id"></param>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("InsertData/{id}")]
    public async Task<ServiceResult<long>> InsertData(long id, [FromBody] InsertGhre_SurveyExtend input) => await _service.InsertData(id, input);

    #endregion

    #region 查询 
    /// <summary>
    /// 查询
    /// </summary> 
    /// <param name="id"></param> 
    /// <returns></returns>
    [HttpPost("QueryData/{id}")]
    public async Task<ServiceResult<InsertGhre_SurveyExtend>> QueryData(long id) => await _service.QueryData(id);

    #endregion

    #region 查询 
    /// <summary>
    /// 查询
    /// </summary> 
    /// <param name="id"></param> 
    /// <returns></returns>
    [HttpPost("QueryESSData/{id}")]
    public async Task<ServiceResult<Ghre_SurveyExtend>> QueryESSData(long id) => await _service.QueryESSData(id);

    /// <summary>
    /// 查询
    /// </summary> 
    /// <param name="id"></param> 
    /// <param name="openClassId">开班ID</param> 
    /// <returns></returns>
    [HttpPost("QueryESSData/{openClassId}/{id}")]
    public async Task<ServiceResult<Ghre_SurveyExtend>> QueryESSDataFromOpenCLass(long id, long openClassId) => await _service.QueryESSData(id, openClassId);

    #endregion

    #region 提交 
    /// <summary>
    /// 提交
    /// </summary> 
    /// <param name="id"></param> 
    /// <param name="input"></param> 
    /// <returns></returns>
    [HttpPost("SubmitESSData/{id}")]
    public async Task<ServiceResult> SubmitESSData(long id, [FromBody] Ghre_SurveyExtend input) => await _service.SubmitESSData(id, input);


    /// <summary>
    /// 提交
    /// </summary> 
    /// <param name="id"></param> 
    /// <param name="input"></param> 
    /// <returns></returns>
    [HttpPost("SubmitESSData/{openClassId}/{id}")]
    public async Task<ServiceResult> SubmitESSDataFromOpenCLass(long id, [FromBody] Ghre_SurveyExtend input, long openClassId) => await _service.SubmitESSData(id, input, openClassId);

    #endregion

    #region 发布 
    /// <summary>
    /// 发布
    /// </summary> 
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost("Publish/{id}")]
    public async Task<ServiceResult> Publish(long id) => await _service.Publish(id);

    #endregion

    #region 统计 
    /// <summary>
    /// 统计
    /// </summary> 
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost("QueryStatistic/{id}")]
    public async Task<ServiceResult<Ghre_SurveyStatistic>> QueryStatistic(long id) => await _service.QueryStatistic(id);

    #endregion

    #region 开始 
    /// <summary>
    /// 开始
    /// </summary> 
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost("Start/{id}")]
    public async Task<ServiceResult> Start(long id) => await _service.Start(id);

    #endregion



    #region 记录 
    /// <summary>
    /// 记录
    /// </summary> 
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost("QueryRecord/{id}")]
    public async Task<dynamic> QueryRecord(long id) => await _service.QueryRecord(id);

    #endregion
}
