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_OpenClassController : BaseController<IGhre_OpenClassServices, Ghre_OpenClass, Ghre_OpenClassDto, InsertGhre_OpenClassInput, EditGhre_OpenClassInput>
{
    public Ghre_OpenClassController(IGhre_OpenClassServices 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_OpenClassDto>> QueryByStatus([FromBody] QueryBody body, string status)
    {
        return await _service.QueryFilterPage(body, $"Status ='{status}'");
    }
    #endregion

    #region 学员
    /// <summary>
    /// 学员查询
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QueryStaff/{Id}")]
    public async Task<ServiceResult<List<Ghre_OpenClassStaffDto>>> QueryStaff(long Id) => await _service.QueryStaff(Id);


    /// <summary>
    /// 学员新增
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <param name="staffIds">员工ID列表</param>
    /// <returns></returns>
    [HttpPost, Route("InsertStaff/{Id}")]
    public async Task<ServiceResult> InsertStaff(long Id, [FromBody] List<int> staffIds) => await _service.InsertStaff(Id, staffIds);


    /// <summary>
    /// 学员删除
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <param name="staffIds">员工ID列表</param>
    /// <returns></returns>
    [HttpPost, Route("DeleteStaff/{Id}")]
    public async Task<ServiceResult> DeleteStaff(long Id, [FromBody] List<int> staffIds) => await _service.DeleteStaff(Id, staffIds);

    /// <summary>
    /// 学员导出
    /// </summary>
    /// <param name="Id">开班ID</param> 
    /// <returns></returns>
    [HttpPost, Route("ExportStaff/{Id}")]
    public async Task<ServiceResult<ExcelData>> ExportStaff(long Id) => await _service.ExportStaff(Id);
    #endregion

    #region 费用
    /// <summary>
    /// 查询团体费用
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QueryGroupFee/{Id}")]
    public async Task<ServiceResult<List<Ghre_OpenClassFeeDto>>> QueryGroupFee(long Id) => await _service.QueryGroupFee(Id);

    /// <summary>
    /// 查询个人费用
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QueryPersonalFee/{Id}")]
    public async Task<ServiceResult<List<Ghre_OpenClassFeeDto>>> QueryPersonalFee(long Id) => await _service.QueryPersonalFee(Id);


    /// <summary>
    /// 学员费用
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <param name="fee">费用信心</param>
    /// <returns></returns>
    [HttpPost, Route("InsertFee/{Id}")]
    public async Task<ServiceResult> InsertFee(long Id, [FromBody] InsertGhre_OpenClassFeeInput fee) => await _service.InsertFee(Id, fee);


    /// <summary>
    /// 费用删除
    /// </summary> 
    /// <param name="ids">费用数据ID列表</param>
    /// <returns></returns>
    [HttpPost, Route("DeleteFee")]
    public async Task<ServiceResult> DeleteFee([FromBody] List<long> ids) => await _service.DeleteFee(ids);
    #endregion

    #region 总结
    /// <summary>
    /// 总结查询
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QuerySummary/{Id}")]
    public async Task<ServiceResult<Ghre_OpenClassDto>> QuerySummary(long Id) => await _service.QuerySummary(Id);


    /// <summary>
    /// 总结新增
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <param name="insert">员工ID列表</param>
    /// <returns></returns>
    [HttpPost, Route("InsertSummary/{Id}")]
    public async Task<ServiceResult> InsertSummary(long Id, [FromBody] InsertGhre_OpenClassInput insert) => await _service.InsertSummary(Id, insert);


    #endregion

    #region 转入已发布
    [HttpPost, Route("TransferPublished/{Id}")]
    public async Task<ServiceResult> TransferPublished(long Id) => await _service.UpdateStatus([Id], "Publish");

    [HttpPost, Route("TransferPublished")]
    public async Task<ServiceResult> TransferPublished([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Publish", "TransferPublished");
    #endregion

    #region 取消发布
    [HttpPost, Route("CancelPublished/{Id}")]
    public async Task<ServiceResult> CancelPublished(long Id) => await _service.UpdateStatus([Id], "Temporary", "CancelPublished");

    [HttpPost, Route("CancelPublished")]
    public async Task<ServiceResult> CancelPublished([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Temporary", "CancelPublished");
    #endregion

    #region 转入已开课
    [HttpPost, Route("TransferOpening/{Id}")]
    public async Task<ServiceResult> TransferOpening(long Id) => await _service.UpdateStatus([Id], "Opening", "TransferOpening");

    [HttpPost, Route("TransferOpening")]
    public async Task<ServiceResult> TransferOpening([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Opening", "TransferOpening");
    #endregion

    #region 取消开课
    [HttpPost, Route("CancelOpening/{Id}")]
    public async Task<ServiceResult> CancelOpening(long Id) => await _service.UpdateStatus([Id], "Publish", "CancelOpening");

    [HttpPost, Route("CancelOpening")]
    public async Task<ServiceResult> CancelOpening([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Publish", "CancelOpening");
    #endregion

    #region 转入已结案
    [HttpPost, Route("TransferClose/{Id}")]
    public async Task<ServiceResult> TransferClose(long Id) => await _service.UpdateStatus([Id], "Close");

    [HttpPost, Route("TransferClose")]
    public async Task<ServiceResult> TransferClose([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Close");
    #endregion

    #region 取消结案
    [HttpPost, Route("CancelClose/{Id}")]
    public async Task<ServiceResult> CancelClose(long Id) => await _service.UpdateStatus([Id], "Opening");

    [HttpPost, Route("CancelClose")]
    public async Task<ServiceResult> CancelClose([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Opening");
    #endregion

    #region 成绩
    /// <summary>
    /// 查询成绩
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QueryScore/{Id}")]
    public async Task<ServiceResult<List<Ghre_OpenClassScore>>> QueryScore(long Id) => await _service.QueryScore(Id);
    #endregion

    #region 报名
    /// <summary>
    /// 报名
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("CheckIn/{Id}")]
    public async Task<ServiceResult> CheckIn(long Id) => await _service.CheckIn(Id);
    #endregion

    #region 课表
    /// <summary>
    /// 查询课表
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QuerySchedule/{Id}")]
    public async Task<ServiceResult<Ghre_OpenClassSchedule1>> QuerySchedule(long Id) => await _service.QuerySchedule(Id);
    #endregion

    #region 签到
    /// <summary>
    /// 签到
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("AttendCheckIn/{Id}")]
    public async Task<ServiceResult> AttendCheckIn(long Id) => await _service.Attend(Id, "CheckIn");
    #endregion

    #region 签退
    /// <summary>
    /// 签退
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("AttendCheckOut/{Id}")]
    public async Task<ServiceResult> AttendCheckOut(long Id) => await _service.Attend(Id, "CheckOut");
    #endregion

    #region 邮件
    /// <summary>
    /// 邮件
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("Email/{Id}")]
    public async Task<ServiceResult> Email(long Id) => await _service.Email(Id);
    #endregion

    #region 统计
    /// <summary>
    /// 统计
    /// </summary>
    /// <param name="Id">开班ID</param>
    /// <returns></returns>
    [HttpPost, Route("QueryStatistic/{Id}")]
    public async Task<ServiceResult<Ghre_OpenClassStatistic>> QueryStatistic(long Id) => await _service.QueryStatistic(Id);
    #endregion
}