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_PlanController : BaseController<IGhre_PlanServices, Ghre_Plan, Ghre_PlanDto, InsertGhre_PlanInput, EditGhre_PlanInput>
{
    public Ghre_PlanController(IGhre_PlanServices 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_PlanDto>> 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 _service.UpdateStatus(input, status);
    }
    #endregion 

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

    #region 牛尾报表查询
    /// <summary>
    /// 根据条件查询数据
    /// </summary>
    /// <param name="body">条件</param>
    /// <returns></returns>
    [HttpPost, Route("QueryUshioPlanReport")]
    public async Task<ServicePageResult<UshioPlanReport>> QueryUshioPlan([FromBody] QueryBody body) => await _service.QueryUshioPlan(body);
    #endregion 

    #region 培训计划达成率——宝连通
    /// <summary>
    /// 培训计划达成率——宝连通
    /// </summary>
    /// <param name="body">条件</param>
    /// <returns></returns>
    [HttpPost, Route("QueryCompletionRateBLT")]
    public async Task<ServicePageResult<CompletionRateBLT>> QueryCompletionRateBLT([FromBody] QueryBody body) => await _service.QueryCompletionRateBLT(body);
    #endregion 
}