using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

/// <summary>
/// 反馈结果管理服务（各机构均适用）
/// </summary>
public class ExamResultService(IRepository<ExamResult> rep) : IExamResultService, ITransient
{
    /// <summary>
    /// 添加监测结果文件
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task Add(AddExamResultInput input)
    {
        var item = input.Adapt<ExamResult>();
        await rep.InsertNowAsync(item);
    }

    /// <summary>
    /// 根据发布内容ID获取文件列表
    /// </summary>
    /// <param name="publishId"></param>
    /// <returns></returns>
    public async Task<List<ExamResultOutput>> GetListByPublishId(int publishId)
    {
        var items = await rep.DetachedEntities.Where(t => t.ExamDataPublishId == publishId).ProjectToType<ExamResultOutput>().ToListAsync();
        return items;
    }
}
