From 34ab5abbb083795de0be4487e8c1b2d83ef7e700 Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:47:57 +0800 Subject: [PATCH] 1 --- Entities/DTO/ExamDto.cs | 26 ++++++++++++++++++- .../Context/AutoMapperProFile.cs | 6 +++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Entities/DTO/ExamDto.cs b/Entities/DTO/ExamDto.cs index 4e13389..c5b82d3 100644 --- a/Entities/DTO/ExamDto.cs +++ b/Entities/DTO/ExamDto.cs @@ -28,6 +28,8 @@ namespace Entities.DTO public string? Descript { get; set; } public List SubQuestions { get; set; } = new List(); public List SubQuestionGroups { get; set; } = new List(); + + // 标记是否是一个具有上下文的单独问题 public bool ValidQuestionGroup { get; set; } = false; } @@ -46,12 +48,34 @@ namespace Entities.DTO public string? QuestionType { get; set; } public string? DifficultyLevel { get; set; } + + // 标记是否是一个独立的问题 public bool ValidQuestion { get; set; } = false; } public class OptionDto { - public string Value { get; set; } + public string? Value { get; set; } = string.Empty; } + + + public static class ExamDtoExtension + { + public static void Convert(this ExamDto examDto) + { + var qg = examDto.QuestionGroups; + + } + + public static void Convert(this QuestionGroupDto examDto) + { + if(examDto.ValidQuestionGroup) + { + + } + + } + } + } diff --git a/TechHelper.Server/Context/AutoMapperProFile.cs b/TechHelper.Server/Context/AutoMapperProFile.cs index e250cc9..226d534 100644 --- a/TechHelper.Server/Context/AutoMapperProFile.cs +++ b/TechHelper.Server/Context/AutoMapperProFile.cs @@ -82,6 +82,12 @@ namespace TechHelper.Context CreateMap() .ForMember(dest => dest.Question, opt => opt.MapFrom(src => src)); // 映射到嵌套的 Question 对象 + CreateMap() + .ForMember(dest => dest.ChildQuestionGroups, opt => opt.MapFrom(src => src.SubQuestionGroups)) + .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Title)) + .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Descript)); + + CreateMap(); }