namespace Tiobon.Core.Api.Controllers;

/// <summary>
/// Ghre_Teacher(Controller)
/// </summary>
[Route("api/[controller]")]
[ApiController, GlobalActionFilter]
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghre)]
public class Ghre_TeacherController : BaseController<IGhre_TeacherServices, Ghre_Teacher, Ghre_TeacherDto, InsertGhre_TeacherInput, EditGhre_TeacherInput>
{
    public Ghre_TeacherController(IGhre_TeacherServices service) : base(service)
    {
    }

    #region 查询 
    [HttpPost("QueryDisabled")]
    public async Task<ServicePageResult<Ghre_TeacherDto>> QueryDisabled([FromBody] QueryBody body)
    {
        return await _service.QueryFilterPage(body, null, false);
    }
    #endregion

    #region 查询
    /// <summary>
    /// 根据条件查询数据
    /// </summary>
    /// <param name="body">条件</param>
    /// <param name="status">status</param>
    /// <returns></returns>
    [HttpPost, Route("QueryList/{status}")]
    public async Task<ServicePageResult<Ghre_TeacherDto>> QueryByStatus([FromBody] QueryBody body, string status)
    {
        if (status == "Active")
            return await _service.QueryFilterPage(body, $"(Status ='{status}' OR (WorkID IS NOT NULL AND WorkState IN (0,1)))");
        else if (status == "Disable")
            return await _service.QueryFilterPage(body, null, false);
        else
            return await _service.QueryFilterPage(body, $"Status ='{status}' AND WorkID IS NULL");
    }
    #endregion

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

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