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_CourseController : BaseController<IGhre_CourseServices, Ghre_Course, Ghre_CourseDto, InsertGhre_CourseInput, EditGhre_CourseInput>
{
    public Ghre_CourseController(IGhre_CourseServices service) : base(service)
    {
    }

    #region 查询
    /// <summary>
    /// 根据条件查询数据
    /// </summary>
    /// <param name="status">status</param>
    /// <param name="body">条件</param>
    /// <returns></returns>
    [HttpPost, Route("QueryList/{status}")]
    public async Task<ServicePageResult<Ghre_CourseDto>> QueryList(string status, [FromBody] QueryBody body)
    {
        return await _service.QueryList(body, status, null);
    }

    [HttpPost, Route("QueryDeptID/{StaffID}")]
    public async Task<ServiceResult<int>> QueryDeptID(int StaffID)
    {
        return await _service.QueryDeptID(StaffID);
    }

    [HttpPost, Route("GetSelect")]
    public async Task<ServiceResult<CommonSelect>> QueryTeacher(long? linkId)
    {
        return await _service.QueryTeacher(linkId);
    }

    #endregion

    #region 更新 
    [HttpPost("UpdateStatus/{status}")]
    public async Task<ServiceResult> UpdateStatus(string status, [FromBody] long[] ids)
    {
        return await _service.UpdateStatus(ids, status);
    }
    #endregion 

    #region 获取通用列表下拉
    /// <summary>
    /// 获取通用列表下拉
    /// </summary>
    /// <param name="linkId"></param>
    /// <param name="KeyWords"></param>
    /// <returns></returns>
    [HttpPost, Route("QuerySelect")]
    public async Task<ServiceResult<CommonSelect>> QuerySelectAsync(long? linkId, string KeyWords)
    {
        return await _service.GetSelectAsync(linkId, KeyWords);
    }
    #endregion

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

    [HttpPost, Route("QueryPublicSearchFields")]
    public async Task<ServiceResult<CoursePublicSearch>> QueryPublicSearchFields([FromBody] QueryBody body)
    {
        return await _service.QueryPublicSearchFields(body);
    }

    [HttpPost, Route("QueryPublic")]
    public async Task<ServicePageResult<CoursePublic>> QueryPublic([FromBody] QueryBody body)
    {
        return await _service.QueryPublic(body);
    }

    [HttpPost, Route("QueryBySceneId/{courseSceneId}")]
    public async Task<ServiceResult<List<Ghre_CourseDto>>> QueryBySceneId(long courseSceneId)
    {
        return await _service.QueryBySceneId(courseSceneId);
    }

    [HttpPost, Route("ModifyCourseSortNo")]
    public async Task<ServiceResult> ModifyCourseSortNo([FromBody] List<Ghre_Course> courses)
    {
        return await _service.ModifyCourseSortNo(courses);
    }

    /// <summary>
    /// 统计
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpPost("QueryStatistic/{id}")]
    public async Task<dynamic> QueryStatistic(long id)
    {
        return await _service.QueryStatistic(id);
    }


    /// <summary>
    /// 统计
    /// </summary>
    /// <param name="filter"></param>
    /// <returns></returns>
    [HttpPost("QueryCourseAndScene")]
    public async Task<ServicePageResult<CourseAndScene>> QueryCourseAndScene([FromBody] QueryBody filter)
    {
        return await _service.QueryCourseAndScene(filter);
    }
}