using Furion.JsonSerialization;
using YBEE.EQM.Core;

namespace YBEE.EQM.Application;

public class ExamSampleMapper : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.ForType<AddExamSampleInput, ExamSample>()
              .Map(d => d.Config, s => JSON.Serialize(s.Config, null))
              ;
        config.ForType<UpdateExamSampleInput, ExamSample>()
              .Map(d => d.Config, s => JSON.Serialize(s.Config, null))
              ;
        config.ForType<ExamSample, ExamSampleOutput>()
              .Map(d => d.Config, s => JSON.Deserialize<ExamSampleConfig>(s.Config, null))
              .Map(d => d.IsFixedExamSample, s => s.ExamPlan.IsFixedExamSample)
              .Map(d => d.EducationStage, s => s.ExamPlan.EducationStage)
              ;
        config.ForType<ExamSample, ExamSamplePlanOutput>()
              .Map(d => d.Config, s => JSON.Deserialize<ExamSampleConfig>(s.Config, null))
              .Map(d => d.IsFixedExamSample, s => s.ExamPlan.IsFixedExamSample)
              .Map(d => d.EducationStage, s => s.ExamPlan.EducationStage)
              ;
    }
}
