using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

/// <summary>
/// 监测数据上报类型管理服务
/// </summary>
[ApiDescriptionSettings(Name = "exam-data-report")]
[Route("exam/data/report")]
public class ExamDataReportAppService : IDynamicApiController
{
    private readonly IExamDataReportService _examDataReportService;
    private readonly IResourceFileService _resourceFileService;

    public ExamDataReportAppService(IExamDataReportService examDataReportService, IResourceFileService resourceFileService)
    {
        _examDataReportService = examDataReportService;
        _resourceFileService = resourceFileService;
    }

    #region 创建更新
    /// <summary>
    /// 添加上报类型
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Add(AddExamDataReportInput input)
    {
        await _examDataReportService.Add(input);
    }
    /// <summary>
    /// 更新上报类型
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Update(UpdateExamDataReportInput input)
    {
        await _examDataReportService.Update(input);
    }
    /// <summary>
    /// 删除上报类型
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Del(BaseId input)
    {
        await _examDataReportService.Del(input);
    }

    /// <summary>
    /// 上传附件
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [RequestSizeLimit(1024 * 1024 * 1024)]
    [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
    public async Task UploadAttachment([FromForm] UploadResourceFileInput input)
    {
        var rfile = await _resourceFileService.Upload(input);
        var addParams = rfile.Adapt<AddAttachmentInput>();
        await _examDataReportService.AddAttachment(addParams);
    }
    /// <summary>
    /// 删除附件
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task DelAttachment(DeleteAttachmentInput input)
    {
        await _examDataReportService.DelAttachment(input);
    }
    #endregion

    #region 状态处理
    /// <summary>
    /// 开始
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Start(BaseId input)
    {
        await _examDataReportService.Start(input);
    }
    /// <summary>
    /// 结束
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Stop(BaseId input)
    {
        await _examDataReportService.Stop(input);
    }
    /// <summary>
    /// 取消
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Cancel(BaseId input)
    {
        await _examDataReportService.Cancel(input);
    }
    #endregion

    #region 查询
    /// <summary>
    /// 根据ID获取监测数据上报类型
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public async Task<ExamDataReportOutput> GetById([FromQuery][Required] int id)
    {
        return await _examDataReportService.GetById(id);
    }
    /// <summary>
    /// 根据监测计划ID获取数据上报类型列表
    /// </summary>
    /// <param name="examPlanId"></param>
    /// <returns></returns>
    public async Task<List<ExamDataReportOutput>> GetListByExamPlanId([FromQuery][Required] int examPlanId)
    {
        return await _examDataReportService.GetListByExamPlanId(examPlanId);
    }
    #endregion
}
