Ver código fonte

DeleteKnowledge 删除知识点时 同时删除 引用该知识点的 SyllabusResource表的points数组中该知道点的id

李思淳 5 anos atrás
pai
commit
5e32dd6be9

+ 3 - 0
TEAMModelOS/Controllers/Syllabus/KnowledgeController.cs

@@ -296,7 +296,10 @@ namespace TEAMModelOS.Controllers.Syllabus
             foreach (Knowledge Knowledge in Knowledges) {
                 if (Knowledge.type == 1) {
                     List<Knowledge> knowledges = await  _cosmos.FindSQL<Knowledge>("SELECT value(c) FROM c join a in c.points where Contains(a, '"+ Knowledge.id + "') = true ",true);
+                    List<SyllabusResource> Resources = await _cosmos.FindSQL<SyllabusResource>("SELECT value(c) FROM c join a in c.points where Contains(a, '" + Knowledge.id + "') = true ", true);
                     foreach (Knowledge knowledge in knowledges) knowledge.points.Remove(Knowledge.id);
+                    foreach (SyllabusResource Resource in Resources) Resource.points.Remove(Knowledge.id);
+                    await _cosmos.SaveAll(Resources);
                     await _cosmos.SaveAll(knowledges);
                 }
             }