namespace Tiobon.Core.Api.Controllers;

/// <summary>
/// 【牛尾】培训计划(Controller)
/// </summary>
[Route("api/[controller]")]
[ApiController, GlobalActionFilter]
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghre)]
public class Ghre_UshioPlanController : BaseController<IGhre_UshioPlanServices, Ghre_UshioPlan, Ghre_UshioPlanDto, InsertGhre_UshioPlanInput, EditGhre_UshioPlanInput>
{
    IGhre_PlanServices _planService;
    public Ghre_UshioPlanController(IGhre_UshioPlanServices service,
        IGhre_PlanServices planService) : base(service)
    {
        _planService = planService;
    }

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

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

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

}