2 Revize cd92bc09a0 ... 28d6f70104

Autor SHA1 Zpráva Datum
  guqiang 28d6f70104 Merge branch 'feature/exam' into dev před 1 dnem
  guqiang 797f28243c 调整培训记录接口 před 1 dnem

+ 17 - 10
src/Hotline.Application/Exam/Service/Trains/TrainRecordService.cs

@@ -296,6 +296,18 @@ namespace Hotline.Application.Exam.Service.Trains
         }
 
         private SqlSugar.ISugarQueryable<SimpleQuestionDto> QueryQuestions(EntityQueryRequest entityQueryRequest)
+        {
+            SqlSugar.ISugarQueryable<ExamTrainRecord, ExamTrainPlan, ExamTrainPlanTemplate, ExamTrainPractice> queryable = QuestionQueryable(entityQueryRequest);
+
+            var result = queryable.Select((r, p, tpt, tp) => new SimpleQuestionDto
+            {
+                Title = tp.Title,
+                Id = tp.Id
+            });
+            return result;
+        }
+
+        private SqlSugar.ISugarQueryable<ExamTrainRecord, ExamTrainPlan, ExamTrainPlanTemplate, ExamTrainPractice> QuestionQueryable(EntityQueryRequest entityQueryRequest)
         {
             var trainPlanRepository = new ExamRepository<ExamTrainPlan>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
             var trainPracticeRepository = new ExamRepository<ExamTrainPractice>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
@@ -308,26 +320,21 @@ namespace Hotline.Application.Exam.Service.Trains
 
             var queryable = trainRecordTable.InnerJoin(trainPlanTable, (r, p) => r.TrainPlanId == p.Id)
                 .InnerJoin(trainPlanTemplateTable, (r, p, tpt) => p.Id == tpt.TrainPlanId)
-                .InnerJoin(trainPracticeTable, (r, p, tpt, tp) => tpt.Id == tp.TrainTemplateId)
-                .Select((r, p, tpt, tp) => new SimpleQuestionDto
-                {
-                    Title = tp.Title,
-                    Id = tp.Id
-                });
+                .InnerJoin(trainPracticeTable, (r, p, tpt, tp) => tpt.TrainTemplateId == tp.TrainTemplateId);
             return queryable;
         }
 
         private async Task<List<SimpleKnowladgeDto>> GetKnowladges(EntityQueryRequest entityQueryRequest)
         {
-            var questionTable = QueryQuestions(entityQueryRequest);
+            var questionTable = QuestionQueryable(entityQueryRequest);
             var questionSourcewareRepository = new ExamRepository<ExamPracticeQuestionSourceware>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
             var sourcewareRepository = new ExamRepository<KnowledgeBase.Knowledge>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
             var questionSourcewareTable = questionSourcewareRepository.Queryable();
             var sourcewareTable = sourcewareRepository.Queryable();
 
-            var queryable = questionTable.InnerJoin(questionSourcewareTable, (r, p) => r.Id == p.QuestionId)
-                .InnerJoin(sourcewareTable, (r, p, sw) => p.SourcewareId == sw.Id)
-                .Select((r, p, sw) => new SimpleKnowladgeDto
+            var queryable = questionTable.InnerJoin(questionSourcewareTable, (r, p, tpt, tp, ExamPracticeQuestionSourceware) => r.Id == ExamPracticeQuestionSourceware.QuestionId)
+                .InnerJoin(sourcewareTable, (r, p, tpt, tp, ExamPracticeQuestionSourceware,sw) => ExamPracticeQuestionSourceware.SourcewareId == sw.Id)
+                .Select((r, p, tpt, tp, ExamPracticeQuestionSourceware, sw) => new SimpleKnowladgeDto
                 {
                     Title = sw.Title,
                     Id = sw.Id

+ 0 - 1
src/Hotline/Validators/Exams/ExamManages/UpdateRuleTagDtoValidator.cs

@@ -11,7 +11,6 @@ namespace Hotline.Validators.Exams.ExamManages
     {
         public UpdateRuleTagDtoValidator()
         {
-            RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTag.Id))));
             RuleFor(m => m.TagId).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, typeof(ExamTag).GetDescription()));
         }
     }

+ 0 - 1
src/Hotline/Validators/Exams/ExamManages/UpdateTagQuestionDtoValidator.cs

@@ -11,7 +11,6 @@ namespace Hotline.Validators.Exams.ExamManages
     {
         public UpdateTagQuestionDtoValidator()
         {
-            RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTagQuestion.Id))));
             RuleFor(m => m.QuestionType).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTagQuestion.QuestionType))));
             RuleFor(m => m.Count).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTagQuestion.Count))));
             RuleFor(m => m.TagId).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, typeof(ExamTag).GetDescription()));

+ 0 - 1
src/Hotline/Validators/Exams/Questions/UpdateQuestionOptionsDtoValidator.cs

@@ -11,7 +11,6 @@ namespace Hotline.Validators.Exams
         public UpdateQuestionOptionsDtoValidator()
         {
             RuleFor(m => m.Content).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestionOptions.Content))));
-            RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamQuestionOptions.Id))));
         }
     }
 }

+ 0 - 1
src/Hotline/Validators/Exams/Questions/UpdateQuestionSourcewareDtoValidator.cs

@@ -13,7 +13,6 @@ namespace Hotline.Validators.Exams.Questions
         public UpdateQuestionSourcewareDtoValidator()
         {
             RuleFor(m => m.SourcewareId).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, typeof(ExamSourceware).GetDescription()));
-            RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamPracticeQuestionSourceware.Id))));
         }
     }
 }

+ 0 - 2
src/Hotline/Validators/Exams/TestPapers/UpdateTestPaperItemDtoValidator.cs

@@ -13,8 +13,6 @@ namespace Hotline.Validators.Exams.TestPapers
         public UpdateTestPaperItemDtoValidator()
         {
             RuleFor(m => m.QuestionId).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, typeof(ExamQuestion).GetDescription()));
-
-            RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTestPaperItem.Id))));
         }
     }
 }

+ 0 - 2
src/Hotline/Validators/Exams/TestPapers/UpdateTestPaperRuleDtoValidator.cs

@@ -14,8 +14,6 @@ namespace Hotline.Validators.Exams.TestPapers
             RuleFor(m => m.QuestionType).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTestPaperRule.QuestionType))));
 
             RuleFor(m => m.Count).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTestPaperRule.QuestionType))));
-
-            RuleFor(m => m.Id).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamTestPaperRule.Id))));
         }
     }
 }