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_StudyRecordController : BaseController<IGhre_StudyRecordServices, Ghre_StudyRecord, Ghre_StudyRecordDto, InsertGhre_StudyRecordInput, EditGhre_StudyRecordInput>
{
    public Ghre_StudyRecordController(IGhre_StudyRecordServices service) : base(service)
    {
    }


    #region 获取ESS查询条件
    /// <summary>
    /// 获取ESS查询条件
    /// </summary>
    /// <param name="body"></param>
    /// <returns></returns>
    [HttpPost, Route("QueryESSSearchFields")]
    public async Task<ServiceResult<CoursePublicSearch>> QueryESSSearchFields([FromBody] QueryBody body)
    {
        return await _service.QueryESSSearchFields(body);
    }
    #endregion

    #region 获取ESS查询条件
    /// <summary>
    /// 获取ESS查询条件
    /// </summary>
    /// <param name="body"></param>
    /// <returns></returns>
    [HttpPost, Route("QueryESS")]
    public async Task<ServicePageResult<Ghre_StudyRecordESS>> QueryESS([FromBody] QueryBody body)
    {
        return await _service.QueryESS(body, "");
    }
    #endregion

    #region 获取学习记录
    /// <summary>
    /// 获取学习记录
    /// </summary>
    /// <param name="body"></param>
    /// <returns></returns>
    [HttpPost, Route("QueryStaff")]
    public async Task<ServicePageResult<Ghre_StudyRecordDto>> QueryStaff([FromBody] QueryBody body)
    {
        return await _service.QueryStaff(body);
    }
    #endregion

    #region 获取课程
    /// <summary>
    /// 获取课程
    /// </summary>
    /// <param name="body"></param>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost, Route("QueryCourse/{id}")]
    public async Task<ServiceResult<Ghre_StudyRecordCourse>> QueryCourse([FromBody] QueryBody body, long id)
    {
        return await _service.QueryCourse(body, id);
    }
    #endregion

    #region 加入学习
    /// <summary>
    /// 加入学习
    /// </summary> 
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost, Route("Join/{id}")]
    public async Task<ServiceResult> Join(long id)
    {
        return await _service.Join(id);
    }
    #endregion


    #region 记录学习时长
    /// <summary>
    /// 记录学习时长
    /// </summary> 
    /// <param name="insert"></param>
    /// <param name="id"></param>
    /// <param name="attachmentId"></param>
    /// <returns></returns>
    [HttpPost, Route("RecordDuration/{id}/{attachmentId}")]
    public async Task<ServiceResult> RecordDuration([FromBody] InsertGhre_StudyRecordInput insert, long id, long attachmentId)
    {
        return await _service.RecordDuration(id, insert.StudyDuration, attachmentId);
    }
    #endregion

    [HttpPost, Route("ExportStaffExcel")]
    public async Task<ServiceResult<ExcelData>> ExportStaffExcel([FromBody] QueryExport body)
    {
        return await _service.ExportStaffExcel(body);
    }

    #region 讲师上课分析
    /// <summary>
    /// 讲师上课分析
    /// </summary>
    /// <param name="body"></param>
    /// <returns></returns>
    [HttpPost, Route("QueryTeacherClassAnalysis")]
    public async Task<ServicePageResult<TeacherClassAnalysis>> QueryTeacherClassAnalysis([FromBody] QueryBody body)
    {
        return await _service.QueryTeacherClassAnalysis(body);
    }
    #endregion
}