namespace YBEE.EQM.Application;

/// <summary>
/// 统计报表之分数段报表服务
/// </summary>
[ApiDescriptionSettings(Name = "exam-reporting-avg-range")]
[Route("exam/reporting/avg/range")]
public class ExamReportingAvgRangeAppService(IExamReportingAvgRangeService examReportingAvgRangeService) : IDynamicApiController
{
    /// <summary>
    /// 导出全区表格
    /// </summary>
    /// <param name="examPlanId">监测计划ID</param>
    /// <returns></returns>
    public async Task<IActionResult> ExportTotal([FromQuery][Required] int examPlanId)
    {
        var (fileName, fileBytes) = await examReportingAvgRangeService.ExportTotal(examPlanId);
        return new FileContentResult(fileBytes, "application/octet-stream")
        {
            FileDownloadName = fileName,
        };
    }
    /// <summary>
    /// 导出各校分数段统计表
    /// </summary>
    /// <param name="examPlanId">监测计划ID</param>
    /// <returns></returns>
    /// <exception cref="Exception"></exception>
    public async Task<IActionResult> ExportOrg([FromQuery][Required] int examPlanId)
    {
        var (fileName, fileBytes) = await examReportingAvgRangeService.ExportOrg(examPlanId);
        return new FileContentResult(fileBytes, "application/octet-stream")
        {
            FileDownloadName = fileName,
        };
    }
}
