فهرست منبع

混合名单查询。

CrazyIter_Bin 3 سال پیش
والد
کامیت
cf584ad709
1فایلهای تغییر یافته به همراه25 افزوده شده و 22 حذف شده
  1. 25 22
      TEAMModelOS.SDK/Models/Service/GroupListService.cs

+ 25 - 22
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -429,30 +429,33 @@ namespace TEAMModelOS.SDK.Models
                         //取差集,减少二次搜寻
                         classes = classes.Except(students.Select(y => y.classId)).ToList();
                     }
-                    string insql = string.Join(",", classes.Select(x => $"'{x}'"));
-                    //搜寻没有关联学生的行政班
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name ,c.periodId  ,c.year from c where c.id in ({insql})",
-                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
-                    {
-                        ///行政班(学生搜寻classId动态返回)class
-                        List<RMember> smembers = new List<RMember>();
-                        RGroupList group = new RGroupList
+                    if (classes.IsNotEmpty()) {
+                        string insql = string.Join(",", classes.Select(x => $"'{x}'"));
+                        //搜寻没有关联学生的行政班
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name ,c.periodId  ,c.year from c where c.id in ({insql})",
+                                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
                         {
-                            id = item.id,
-                            code = $"GroupList-{school}",
-                            name = item.name,
-                            periodId = item.periodId,
-                            scope = "school",
-                            school = school,
-                            type = "class",
-                            year = item.year,
-                            members = smembers,
-                            scount = smembers.Count
-                        };
-                        groupLists.Add(group);
+                            ///行政班(学生搜寻classId动态返回)class
+                            List<RMember> smembers = new List<RMember>();
+                            RGroupList group = new RGroupList
+                            {
+                                id = item.id,
+                                code = $"GroupList-{school}",
+                                name = item.name,
+                                periodId = item.periodId,
+                                scope = "school",
+                                school = school,
+                                type = "class",
+                                year = item.year,
+                                members = smembers,
+                                scount = smembers.Count
+                            };
+                            groupLists.Add(group);
+                        }
+                        //取差集,减少二次搜寻
+                        classes = classes.Except(groupLists.Select(y => y.id)).ToList();
                     }
-                    //取差集,减少二次搜寻
-                    classes = classes.Except(students.Select(y => y.classId)).ToList();
+                   
                 }
                 if (classes.IsNotEmpty())
                 {