Ver código fonte

修改查询表

CrazyIter_Bin 3 anos atrás
pai
commit
292aa7a0a2

+ 1 - 1
TEAMModelFunction/ActivityHttpTrigger.cs

@@ -103,7 +103,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(tmdCourse, new PartitionKey(tmdCourse.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(tmdCourse, new PartitionKey(tmdCourse.code));
                             }
                         }
                     }

+ 12 - 55
TEAMModelFunction/CourseServiceBus.cs

@@ -80,12 +80,12 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             if (!stuCourse.Value.classId.Contains(cls))
                             {
                                 stuCourse.Value.classId.Add(cls);
                             }
-                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                         }
                         catch (CosmosException ex)
                         {
@@ -104,7 +104,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
                             }
                         }
                     }
@@ -149,11 +149,11 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             if (!stuCourse.Value.stulist.Contains(list))
                             {
                                 stuCourse.Value.stulist.Add(list);
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
                             
                         }
@@ -174,7 +174,7 @@ namespace TEAMModelFunction
                                     pk = "StuCourse",
                                     createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                                 };
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey(course.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(course, new PartitionKey(course.code));
                             }
                         }
                     }
@@ -212,7 +212,7 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
 
                             if (stuCourse.Value.classId.Contains(delCls))
                             {
@@ -222,11 +222,11 @@ namespace TEAMModelFunction
                             if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
                             {
                                 //当两个列表都不存在时则直接删除
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
                             else
                             {
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
 
                         }
@@ -270,7 +270,7 @@ namespace TEAMModelFunction
                     {
                         try
                         {
-                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                            ItemResponse<StuCourse> stuCourse = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
 
                             if (stuCourse.Value.stulist.Contains(delList))
                             {
@@ -280,11 +280,11 @@ namespace TEAMModelFunction
                             if (!stuCourse.Value.classId.IsNotEmpty() && !stuCourse.Value.stulist.IsNotEmpty())
                             {
                                 //当两个列表都不存在时则直接删除
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuCourse>(courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
                             else
                             {
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuCourse>(stuCourse, courseChange.id, new PartitionKey($"StuCourse-{tmd.id}"));
                             }
 
                         }
@@ -294,49 +294,6 @@ namespace TEAMModelFunction
                         }
                     }
                 }
-
-                ////根据新增名单获取 新增的学生id 及timdid
-                //(List<string> addTmdids, List<Students> addStudents) = await TriggerStuActivity.GetStuList(client, _dingDing, courseChange.addList, courseChange.school);
-                ////根据删除名单获取 新增的学生id 及timdid
-                //(List<string> delTmdids, List<Students> delStudents) = await TriggerStuActivity.GetStuList(client, _dingDing, courseChange.delList, courseChange.school);
-                //foreach (var addStu in addStudents)
-                //{
-                //    var course = new StuCourse
-                //    {
-                //        id = courseChange.id,
-                //        scode = courseChange.code,
-                //        name = courseChange.name,
-                //        code = $"StuCourse-{courseChange.school}-{addStu.id}",
-                //        scope = courseChange.scope,
-                //        school = courseChange.school,
-                //        creatorId = courseChange.creatorId,
-                //        pk = "StuCourse"
-                //    };
-                //    await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(course, new PartitionKey(course.code));
-                //}
-                //foreach (var addTmd in addTmdids)
-                //{
-                //    var course = new StuCourse
-                //    {
-                //        id = courseChange.id,
-                //        scode = courseChange.code,
-                //        name = courseChange.name,
-                //        code = $"StuCourse-{addTmd}",
-                //        scope = courseChange.scope,
-                //        //school = courseChange.school,
-                //        creatorId = courseChange.creatorId,
-                //        pk = "StuCourse"
-                //    };
-                //    await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(course, new PartitionKey(course.code));
-                //}
-                //foreach (var delStu in delStudents)
-                //{
-                //    await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{courseChange.school}-{delStu.id}"));
-                //}
-                //foreach (var delTmd in delTmdids)
-                //{
-                //    await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(courseChange.id, new PartitionKey($"Course-{delTmd}"));
-                //}
             }
             catch (Exception ex)
             {

+ 5 - 5
TEAMModelOS.SDK/Models/Service/StuListService.cs

@@ -117,14 +117,14 @@ namespace TEAMModelFunction
                             classIds = classes
                         }; 
                         await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixActivity\n名单发生变更 新建活动中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                     foreach (Students students in stuListChange.stuleave)
                     {
                         try
                         {
 
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{students.code.Replace("Base-", "")}-{students.id}"));
+                            await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{students.code.Replace("Base-", "")}-{students.id}"));
                         }
                         catch (CosmosException ex)
                         {
@@ -136,7 +136,7 @@ namespace TEAMModelFunction
                         try
                         {
 
-                            await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{tmdid}"));
+                            await client.GetContainer("TEAMModelOS", "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{tmdid}"));
                         }
                         catch(CosmosException ex )
                         {
@@ -211,7 +211,7 @@ namespace TEAMModelFunction
                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                     };
                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                    await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                    await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                 }
                 //移除名单的。 在点击相关的课程,再去二次校验是否存在,不存在则再去删除。
                 foreach (var delStu in stuListChange.stuleave)
@@ -220,7 +220,7 @@ namespace TEAMModelFunction
                 }
                 foreach (var delTmd in stuListChange.tmdhleave)
                 {
-                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(course.id, new PartitionKey($"Course-{delTmd}"));
+                    await client.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync(course.id, new PartitionKey($"Course-{delTmd}"));
                 }
             }
         }

+ 3 - 3
TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs

@@ -59,7 +59,7 @@ namespace TEAMModelFunction
                             taskStatus = -1,
                             classIds = classes
                         };
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                     }
                 }
                 if (students.IsNotEmpty())
@@ -105,7 +105,7 @@ namespace TEAMModelFunction
                 {
                     foreach (var x in tmdActivities)
                     {
-                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(x, new PartitionKey(x.code));
+                        await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(x, new PartitionKey(x.code));
                     }
                 }
             } catch (Exception ex) {
@@ -230,7 +230,7 @@ namespace TEAMModelFunction
                     tmdids.ForEach(x => { inids.Add($"'{x}'"); });
                     var insql = string.Join(",", inids);
                     var queryslt = $"SELECT  value(c) FROM c where c.id in ({insql})";
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
                     {
                         infos.Add(item);
                     }