Преглед на файлове

fix: 获取章节对应知识点的时候需要过滤isDeleted

gwd преди 1 седмица
родител
ревизия
44f458ff7a
променени са 3 файла, в които са добавени 25 реда и са изтрити 1 реда
  1. 12 0
      app/Services/DiagnosticChapterService.php
  2. 9 0
      app/Services/ExamTypeStrategy.php
  3. 4 1
      app/Services/LearningAnalyticsService.php

+ 12 - 0
app/Services/DiagnosticChapterService.php

@@ -46,6 +46,9 @@ class DiagnosticChapterService
 
             $kpCodes = TextbookChapterKnowledgeRelation::query()
                 ->whereIn('catalog_chapter_id', $sectionIds)
+                ->where(function ($q) {
+                    $q->where('is_deleted', 0)->orWhereNull('is_deleted');
+                })
                 ->pluck('kp_code')
                 ->filter()
                 ->unique()
@@ -107,6 +110,9 @@ class DiagnosticChapterService
 
         $kpCodes = TextbookChapterKnowledgeRelation::query()
             ->whereIn('catalog_chapter_id', $sectionIds)
+            ->where(function ($q) {
+                $q->where('is_deleted', 0)->orWhereNull('is_deleted');
+            })
             ->pluck('kp_code')
             ->filter()
             ->unique()
@@ -162,6 +168,9 @@ class DiagnosticChapterService
 
             $kpCodes = TextbookChapterKnowledgeRelation::query()
                 ->whereIn('catalog_chapter_id', $sectionIds)
+                ->where(function ($q) {
+                    $q->where('is_deleted', 0)->orWhereNull('is_deleted');
+                })
                 ->pluck('kp_code')
                 ->filter()
                 ->unique()
@@ -269,6 +278,9 @@ class DiagnosticChapterService
 
         $kpCodes = TextbookChapterKnowledgeRelation::query()
             ->whereIn('catalog_chapter_id', $sectionIds)
+            ->where(function ($q) {
+                $q->where('is_deleted', 0)->orWhereNull('is_deleted');
+            })
             ->pluck('kp_code')
             ->filter()
             ->unique()

+ 9 - 0
app/Services/ExamTypeStrategy.php

@@ -1143,6 +1143,9 @@ class ExamTypeStrategy
             $allKpData = DB::table('textbook_chapter_knowledge_relation as tckr')
                 ->join('textbook_catalog_nodes as tcn', 'tckr.catalog_chapter_id', '=', 'tcn.id')
                 ->whereIn('tckr.catalog_chapter_id', $chapterIds)
+                ->where(function ($q) {
+                    $q->where('tckr.is_deleted', 0)->orWhereNull('tckr.is_deleted');
+                })
                 ->select('tckr.kp_code', 'tcn.sort_order', 'tcn.id as chapter_id', 'tcn.title as chapter_title')
                 ->orderBy('tcn.sort_order', 'asc')
                 ->orderBy('tckr.kp_code', 'asc')
@@ -1258,6 +1261,9 @@ class ExamTypeStrategy
             // 修复方案1:使用GROUP BY替代DISTINCT,并选择需要的字段
             $kpCodes = DB::table('textbook_chapter_knowledge_relation')
                 ->whereIn('catalog_chapter_id', $chapterIds)
+                ->where(function ($q) {
+                    $q->where('is_deleted', 0)->orWhereNull('is_deleted');
+                })
                 ->select('kp_code')
                 ->groupBy('kp_code')
                 ->pluck('kp_code')
@@ -1529,6 +1535,9 @@ class ExamTypeStrategy
             $stats = DB::table('textbook_chapter_knowledge_relation as tckr')
                 ->join('textbook_catalog_nodes as tcn', 'tckr.catalog_chapter_id', '=', 'tcn.id')
                 ->whereIn('tckr.catalog_chapter_id', $chapterIdList)
+                ->where(function ($q) {
+                    $q->where('tckr.is_deleted', 0)->orWhereNull('tckr.is_deleted');
+                })
                 ->select(
                     'tckr.catalog_chapter_id as chapter_id',
                     'tcn.title as chapter_title',

+ 4 - 1
app/Services/LearningAnalyticsService.php

@@ -3103,7 +3103,10 @@ class LearningAnalyticsService
             $query = DB::table('textbook_chapter_knowledge_relation as tckr')
                 ->join('textbook_catalog_nodes as tcn', 'tckr.catalog_chapter_id', '=', 'tcn.id')
                 ->join('textbooks as t', 'tcn.textbook_id', '=', 't.id')
-                ->where('t.grade', $grade);
+                ->where('t.grade', $grade)
+                ->where(function ($q) {
+                    $q->where('tckr.is_deleted', 0)->orWhereNull('tckr.is_deleted');
+                });
 
             // 【修复超纲问题】如果有 textbook_id,严格限制在该教材范围内
             // 避免七年级上册学生拿到七年级下册的知识点