Browse Source

调整题库接口

guqiang 6 giờ trước cách đây
mục cha
commit
db6d534f11

+ 20 - 2
src/Hotline.Application/Exam/Service/Questions/QuestionService.cs

@@ -147,9 +147,9 @@ namespace Hotline.Application.Exam.Service.Questions
 
 
             var queryable = questionTable.InnerJoin(questionTagTable, (s, d) => s.Id == d.QuestionId).InnerJoin(examTagTable, (s,d, t) => d.TagId == t.Id)
-                .InnerJoin(questionKnowladgeTable, (s, d, t,k) => s.Id == k.QuestionId)
+                //.InnerJoin(questionKnowladgeTable, (s, d, t,k) => s.Id == k.QuestionId)
             .Distinct()
-            .Select((s, d, t, k) => new QuestionViewResponse
+            .Select((s, d, t) => new QuestionViewResponse
             {
                 DifficultyLevel = s.DifficultyLevel,
                 FormalEnable = s.FormalEnable,
@@ -161,6 +161,24 @@ namespace Hotline.Application.Exam.Service.Questions
                 Id = s.Id
             });
 
+            if (queryRequest.KnowladgeIds != null && queryRequest.KnowladgeIds.Any())
+            {
+                    queryable = questionTable.InnerJoin(questionTagTable, (s, d) => s.Id == d.QuestionId).InnerJoin(examTagTable, (s, d, t) => d.TagId == t.Id)
+                    .InnerJoin(questionKnowladgeTable, (s, d, t, k) => s.Id == k.QuestionId)
+                .Distinct()
+                .Select((s, d, t) => new QuestionViewResponse
+                {
+                    DifficultyLevel = s.DifficultyLevel,
+                    FormalEnable = s.FormalEnable,
+                    SimulateEnable = s.SimulateEnable,
+                    SortIndex = s.SortIndex,
+                    Status = s.Status,
+                    QuestionType = s.QuestionType,
+                    Title = s.Title,
+                    Id = s.Id
+                });
+            }
+
             var list = await queryable.ToPageListAsync(queryRequest.PageIndex, queryRequest.PageSize);
             var total = await queryable.CountAsync();