ExamSampleMapper.cs 1.1 KB

123456789101112131415161718192021222324252627
  1. using Furion.JsonSerialization;
  2. using YBEE.EQM.Core;
  3. namespace YBEE.EQM.Application;
  4. public class ExamSampleMapper : IRegister
  5. {
  6. public void Register(TypeAdapterConfig config)
  7. {
  8. config.ForType<AddExamSampleInput, ExamSample>()
  9. .Map(d => d.Config, s => JSON.Serialize(s.Config, null))
  10. ;
  11. config.ForType<UpdateExamSampleInput, ExamSample>()
  12. .Map(d => d.Config, s => JSON.Serialize(s.Config, null))
  13. ;
  14. config.ForType<ExamSample, ExamSampleOutput>()
  15. .Map(d => d.Config, s => JSON.Deserialize<ExamSampleConfig>(s.Config, null))
  16. .Map(d => d.IsFixedExamSample, s => s.ExamPlan.IsFixedExamSample)
  17. .Map(d => d.EducationStage, s => s.ExamPlan.EducationStage)
  18. ;
  19. config.ForType<ExamSample, ExamSamplePlanOutput>()
  20. .Map(d => d.Config, s => JSON.Deserialize<ExamSampleConfig>(s.Config, null))
  21. .Map(d => d.IsFixedExamSample, s => s.ExamPlan.IsFixedExamSample)
  22. .Map(d => d.EducationStage, s => s.ExamPlan.EducationStage)
  23. ;
  24. }
  25. }