瀏覽代碼

调整名单架构后端关联业务代码。

CrazyIter_Bin 3 年之前
父節點
當前提交
466b379851

+ 4 - 4
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -819,7 +819,7 @@ namespace TEAMModelOS.SDK.Models
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixActivity\n{ex.Message}{ex.StackTrace}{groupChange.ToJsonString()}{type}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-GroupListService-FixActivity\n{ex.Message}{ex.StackTrace}{groupChange.ToJsonString()}{type}", GroupNames.醍摩豆服務運維群組);
             }
         }
         public static async Task FixStuCourse(CosmosClient client, DingDing _dingDing, GroupChange groupChange)
@@ -844,7 +844,7 @@ namespace TEAMModelOS.SDK.Models
                 }
             }
             long nowtime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-            // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 需要处理的课程\n{courses.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+            // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-GroupListService-FixStuCourse\n名单发生变更 需要处理的课程\n{courses.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             //2.获取课程的id 并尝试添加或移除对应的学生课程记录StuCourse。
             foreach (var course in courses)
             {
@@ -864,7 +864,7 @@ namespace TEAMModelOS.SDK.Models
                         stulist = new List<string> { groupChange.listid },
                         createTime = nowtime
                     };
-                    // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                    // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-GroupListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                     await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                 }
                 //tmd新加入的
@@ -883,7 +883,7 @@ namespace TEAMModelOS.SDK.Models
                         stulist = new List<string> { groupChange.listid },
                         createTime = nowtime
                     };
-                    // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                    // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-GroupListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                     await client.GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
                 }
                 //移除名单的。 在点击相关的课程,再去二次校验是否存在,不存在则再去删除。

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

@@ -35,10 +35,12 @@ namespace TEAMModelOS.SDK
             if (activity != null)
             {
                 List<string> classes = ExamService.getClasses(activity.classes, activity.stuLists);
-                (List<TmdInfo> tmdids, List<StuInfo> students, List<ClassListInfo> classLists) = await GetStuList(client, _dingDing, classes, activity.school);
+                (List<RMember> tmdIds, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, classes, activity.school);
+                var students = tmdIds.FindAll(x => x.type == 2);
+                var tmdids = tmdIds.FindAll(x => x.type == 1);
                 if (tmdids.IsNotEmpty())
                 {
-                    foreach (TmdInfo tmdid in tmdids)
+                    foreach (RMember tmdid in tmdids)
                     {
                         var stucourse = new StuActivity
                         {
@@ -66,7 +68,7 @@ namespace TEAMModelOS.SDK
                 }
                 if (students.IsNotEmpty())
                 {
-                    foreach (StuInfo student in students)
+                    foreach (RMember student in students)
                     {
                         var stucourse = new StuActivity
                         {

+ 19 - 21
TEAMModelOS/Controllers/Common/CommonController.cs

@@ -119,27 +119,25 @@ namespace TEAMModelOS.Controllers.Common
         /// </summary>
         /// <param name="element"></param>
         /// <returns></returns>
-        [ProducesDefaultResponseType]
-       // [AuthToken(Roles = "teacher,admin")]
-        [HttpPost("get-class-info")]
-        public async Task<IActionResult> GetClassInfo(JsonElement element)
-        {
-            //var (id, school) = HttpContext.GetAuthTokenInfo();
-            try
-            {
-                var client = _azureCosmos.GetCosmosClient();
-                if (!element.TryGetProperty("classes", out JsonElement _classes)) return BadRequest();
-                if (!element.TryGetProperty("school", out JsonElement _school)) return BadRequest();
-                List<string> classes = _classes.ToObject<List<string>>();
-                var classInfos=await TriggerStuActivity.GetClassInfo(client, _dingDing, classes, $"{_school}");
-                return Ok(new { classInfos ,code = 200 });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},common/get-class-info\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest();
-            }
-        }
+        //[ProducesDefaultResponseType]
+        //[HttpPost("get-class-info")]
+        //public async Task<IActionResult> GetClassInfo(JsonElement element)
+        //{
+        //    try
+        //    {
+        //        var client = _azureCosmos.GetCosmosClient();
+        //        if (!element.TryGetProperty("classes", out JsonElement _classes)) return BadRequest();
+        //        if (!element.TryGetProperty("school", out JsonElement _school)) return BadRequest();
+        //        List<string> classes = _classes.ToObject<List<string>>();
+        //        var classInfos=await TriggerStuActivity.GetClassInfo(client, _dingDing, classes, $"{_school}");
+        //        return Ok(new { classInfos ,code = 200 });
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        await _dingDing.SendBotMsg($"OS,{_option.Location},common/get-class-info\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+        //        return BadRequest();
+        //    }
+        //}
         //立即结束某个活动
         [ProducesDefaultResponseType]
         [AuthToken(Roles = "teacher,admin")]

+ 0 - 2
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -486,8 +486,6 @@ namespace TEAMModelOS.Controllers.Learn
                                 }
                             }
                             else {
-                                //(List<TmdInfo> tmdinfos, List<StuInfo> students, List<ClassListInfo> classInfo) = await TriggerStuActivity.GetStuListInStu(client, _dingDing, listIds, school);
-
                                 if (addTmdidsCls.IsNotEmpty())
                                 {
                                     addTmdidsCls.ForEach(x => {

+ 0 - 284
TEAMModelOS/Controllers/School/ClassController.cs

@@ -197,267 +197,6 @@ namespace TEAMModelOS.Controllers
             }
         }
 
-        //
-        
-        [ProducesDefaultResponseType]
-        //[AuthToken(Roles = "teacher")]
-        [HttpPost("find-students")]
-        public async Task<IActionResult> FindStudents(JsonElement request)
-        {
-            try
-            {
-                var client = _azureCosmos.GetCosmosClient();
-                if (!request.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
-                request.TryGetProperty("school_code", out JsonElement schoolId);
-                List<string> classes = ids.ToObject<List<string>>();
-                List<dynamic> list = new List<dynamic>();
-                foreach (string cls in classes) {
-                    //(List<TmdInfo> tmdids, List<StuInfo> students, List<ClassListInfo> classLists) = await TriggerStuActivity.GetStuListInStu(client, _dingDing, new List<string> { cls }, $"{schoolId}");
-                    (List<RMember> tchList, List<RGroupList> classLists) = await GroupListService.GetStutmdidListids(client, _dingDing, new List<string> { cls }, $"{schoolId}");
-                    var addStudentsCls = tchList.FindAll(x => x.type == 2);
-                    var addTmdidsCls = tchList.FindAll(x => x.type == 1);
-                    if (classLists.IsNotEmpty()) {
-                        list.Add(new { addTmdidsCls, addStudentsCls, @class= classLists.First() });
-                    }
-                }
-                return Ok(new { list });
-            }
-            catch (CosmosException ex) {
-                await _dingDing.SendBotMsg($"IES5,{_option.Location},find-new-students()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest();
-            }
-        }
-            [ProducesDefaultResponseType]
-        //[AuthToken(Roles = "teacher")]
-        [HttpPost("find-student")]
-        public async Task<IActionResult> FindStudent(JsonElement requert)
-        {
-            //ResponseBuilder builder = ResponseBuilder.custom();
-            //if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-            if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
-            if (!requert.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
-            if (!requert.TryGetProperty("school_code", out JsonElement schoolId)) return BadRequest();
-            try
-            {
-                var client = _azureCosmos.GetCosmosClient();
-                List<object> stus = new List<object>();
-                List<string> stuIds = new List<string>();
-                string info = "";
-                for (int i = 0; i < ids.GetArrayLength(); i++)
-                {
-                    //ids.Add(id[i].ToJsonString());
-                    info += ids[i].ToJsonString() + ",";
-                }
-                //List<object> scList = new List<object>();
-                List<object> suList = new List<object>();
-                List<(string id, string name, string pic, string code, string classId ,string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)>();
-                //var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(ids[i].GetString(), new PartitionKey($"Class-{schoolId}"));
-                //string className = "";
-                /*                if (response.Status == 200)
-                                {
-                                    using var document = await JsonDocument.ParseAsync(response.ContentStream);
-                                    Class @class = document.ToObject<Class>();
-                                    className = @class.name;
-                                }*/
-                List<(string id, string name)> listClassList = new List<(string id,string name)>();
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
-                                    queryText: $"select c.id,c.name from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            listClassList.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
-                            //stuIds.Add(account.GetProperty("id").GetString());                           
-                        }
-                    }
-                }
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
-                    queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.classId in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
-                {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            stuIds.Add(account.GetProperty("id").GetString());
-
-                            listStudent.Add((account.GetProperty("id").GetString(),
-                                account.GetProperty("name").GetString(),
-                                account.GetProperty("picture").GetString(),
-                                account.GetProperty("code").GetString(),
-                                account.GetProperty("classId").GetString(),
-                                account.GetProperty("groupId").GetString(),
-                                account.GetProperty("groupName").GetString(),
-                                account.GetProperty("no").GetString()));
-                        }
-                    }
-                }
-                var grpBalance = listStudent.GroupBy(m => new { m.classId }).Distinct().Select(t =>t.ToList().Select(o =>
-                                    new
-                                    {
-                                        o.id,
-                                        o.name,
-                                        o.pic,
-                                        o.code,
-                                        o.classId,
-                                        className = listClassList.FirstOrDefault(c => c.id == o.classId).name,
-                                        o.groupId,
-                                        o.groupName,
-                                        o.no
-                                    })
-                );
-                stus.AddRange(grpBalance);
-                //处理校本的自定义名单
-                List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)> listStuList = new List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)>();
-                List<(string id, string code, string stuId, string name)> stuListMore = new List<(string id, string code, string stuId, string name)>();
-                if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
-                {
-                    List<StuList> stuLists = new List<StuList>();
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
-                    {
-                        stuLists.Add(item);
-                    }
-                    List<string> stuInfo = new List<string>();
-                    if (stuLists.Count > 0)
-                    {
-                        foreach (StuList stuList in stuLists)
-                        {
-                            foreach (Students stu in stuList.students)
-                            {
-                                stuInfo.Add(stu.id);
-                                stuListMore.Add((stu.id,
-                                                stu.code,
-                                                stuList.id,
-                                                stuList.name));
-                            }
-
-                        }
-                        //根据学生ID  CODE获取学生基本信息
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
-                       queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.id in ({string.Join(",", stuInfo.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
-                        {
-                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                            {
-                                var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                                while (accounts.MoveNext())
-                                {
-                                    JsonElement account = accounts.Current;
-                                    listStuList.Add((account.GetProperty("id").GetString(),
-                                        account.GetProperty("name").GetString(),
-                                        account.GetProperty("picture").GetString(),
-                                        account.GetProperty("code").GetString(),
-                                        account.GetProperty("classId").GetString(),
-                                        account.GetProperty("groupId").GetString(),
-                                        account.GetProperty("groupName").GetString(),
-                                        account.GetProperty("no").GetString()));
-                                }
-                            }
-                        }
-                        var infos = stuListMore.GroupBy(m => new { m.stuId }).Distinct().Select(t =>
-                             t.ToList().Select(o =>
-                                    new
-                                    {
-                                        o.id,
-                                        o.code,
-                                        name = listStuList.FirstOrDefault(c => c.id == o.id).name,
-                                        pic = listStuList.FirstOrDefault(c => c.id == o.id).pic,
-                                        classId = o.stuId,
-                                        className = o.name,
-                                        groupId = listStuList.FirstOrDefault(c => c.id == o.id).groupId,
-                                        groupName = listStuList.FirstOrDefault(c => c.id == o.id).groupName,
-                                        no = listStuList.FirstOrDefault(c => c.id == o.id).no
-                                    })
-                        );
-                        stus.AddRange(infos);
-                    }                                                        
-                }
-                else
-                {
-                    //处理发布对象为自选名单(个人)
-                    List<StuList> stuLists1 = new List<StuList>();
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
-                    {
-                        stuLists1.Add(item);
-                    }
-                    if (stuLists1.Count > 0)
-                    {
-                        foreach (StuList stuList in stuLists1)
-                        {
-                            foreach (Students students in stuList.students)
-                            {
-                                //根据学生ID  CODE获取学生基本信息
-                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
-                               queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.id = '{students.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{students.code}") }))
-                                {
-                                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                                    {
-                                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                                        while (accounts.MoveNext())
-                                        {
-                                            JsonElement account = accounts.Current;
-                                            listStuList.Add((account.GetProperty("id").GetString(),
-                                                account.GetProperty("name").GetString(),
-                                                account.GetProperty("picture").GetString(),
-                                                account.GetProperty("code").GetString(),
-                                                account.GetProperty("classId").GetString(),
-                                                account.GetProperty("groupId").GetString(),
-                                                account.GetProperty("groupName").GetString(),
-                                                account.GetProperty("no").GetString()));
-                                        }
-                                    }
-                                }
-                                stuListMore.Add((students.id,
-                                                students.code,
-                                                stuList.id,
-                                                stuList.name));
-                            }
-                            if (stuList.tmids.Count > 0)
-                            {
-                                foreach (string tid in stuList.tmids)
-                                {
-                                    stuListMore.Add((tid,
-                                                default,
-                                                stuList.id,
-                                                stuList.name));
-                                }
-                            }
-                        }
-                        var infos = stuListMore.GroupBy(m => new { m.stuId }).Distinct().Select(t => 
-                            t.ToList().Select(o =>
-                                    new
-                                    {
-                                        o.id,
-                                        o.code,
-                                        name = listStuList.FirstOrDefault(c => c.id == o.id).name,
-                                        pic = listStuList.FirstOrDefault(c => c.id == o.id).pic,
-                                        classId = o.stuId,
-                                        className = o.name,
-                                        groupId = listStuList.FirstOrDefault(c => c.id == o.id).groupId,
-                                        groupName = listStuList.FirstOrDefault(c => c.id == o.id).groupName,
-                                        no = listStuList.FirstOrDefault(c => c.id == o.id).no
-                                    })
-                        );
-                        stus.AddRange(infos);
-                    }
-                }             
-                return Ok(new { stus });
-            }
-            catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},class/FindStudent()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest();
-            }
-
-        }
-
         [ProducesDefaultResponseType]
         //[AuthToken(Roles = "teacher")]
         [HttpPost("delete")]
@@ -472,8 +211,6 @@ namespace TEAMModelOS.Controllers
                 string school_code = code.ToString();
                 Class classroom = new Class();
                 var client = _azureCosmos.GetCosmosClient();
-/*                if (scope.ToString().Equals("school"))
-                {*/
                     classroom = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{school_code}"));
                     //List<TeacherCourse> classes = new List<TeacherCourse>();
 
@@ -524,27 +261,6 @@ namespace TEAMModelOS.Controllers
                 await _dingDing.SendBotMsg($"OS,{_option.Location},class/Delete()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
-            //ResponseBuilder builder = ResponseBuilder.custom();
-            /*List<IdPk> idPks = new List<IdPk>();
-            if (request.TryGetProperty("id", out JsonElement id))
-            {
-                List<Classroom> sc = await _azureCosmos.FindByDict<Classroom>(request);
-                if (sc.IsNotEmpty())
-                {
-                    await _azureCosmos.DeleteAll<ClassStudent>(new Dictionary<string, object> { { "id", sc.Select(x => x.code).ToArray() } });
-                    idPks = await _azureCosmos.DeleteAll<Classroom>(sc);
-                    //builder.Data(idPks);
-                }
-            }
-            else
-            {
-                return Ok(new { erro = ResponseCode.PARAMS_ERROR, V = "参数未定义!" });
-            }
-            return Ok(new { idPks });*/
-            /*List<VoteRecord> sc = await _azureCosmos.FindByDict<VoteRecord>(request);
-            await _azureCosmos.DeleteAll<VoteRecord>(sc);
-            return Ok();*/
-            //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync("", new PartitionKey($"Class-{code}"));
         }
 
         [ProducesDefaultResponseType]

+ 10 - 51
TEAMModelOS/Controllers/School/CourseController.cs

@@ -450,18 +450,9 @@ namespace TEAMModelOS.Controllers
                     if (schedules.Count > 0)
                     {
                         var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupList>(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList") }))
                         {
-                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                            {
-                                var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                                while (accounts.MoveNext())
-                                {
-                                    JsonElement account = accounts.Current;
-                                    sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), "stuList"));
-                                }
-                            }
+                            sName.Add((item.id, item.name, "stuList"));
                         }
                     }
                     ps.Add((s, n, sc, sName));
@@ -494,18 +485,9 @@ namespace TEAMModelOS.Controllers
                         if (schedules.Count > 0)
                         {
                             var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
-                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId.GetString()}") }))
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{schoolId.GetString()}") }))
                             {
-                                using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                                {
-                                    var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                                    while (accounts.MoveNext())
-                                    {
-                                        JsonElement account = accounts.Current;
-                                        sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), "stuList"));
-                                    }
-                                }
+                                sName.Add((item.id, item.name, "stuList"));
                             }
                             var queryClass = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.classId}'"))})";
                             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId.GetString()}") }))
@@ -1196,41 +1178,20 @@ namespace TEAMModelOS.Controllers
                         {
                             JsonElement account = accounts.Current;
                             listClassList.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
-                            //stuIds.Add(account.GetProperty("id").GetString());                           
                         }
                     }
                 }
 
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
-                                    queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(
+                                    queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            listClassList.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
-                            //stuIds.Add(account.GetProperty("id").GetString());                           
-                        }
-                    }
+                    listClassList.Add((item.id, item.name));
                 }
 
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
-                                    queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupList>(
+                                    queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                    {
-                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                        while (accounts.MoveNext())
-                        {
-                            JsonElement account = accounts.Current;
-                            listClassList.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
-                            //stuIds.Add(account.GetProperty("id").GetString());                           
-                        }
-                    }
+                    listClassList.Add((item.id, item.name));
                 }
             }
 
@@ -1243,8 +1204,6 @@ namespace TEAMModelOS.Controllers
                                         name = listClassList.FirstOrDefault(c => c.id == o.id).name,
                                     }
                );
-            //courses.Add(grpBalance);
-            //courses = courses.Distinct().ToList();
             return Ok(new { courses });
         }
 

+ 107 - 107
TEAMModelOS/Controllers/School/StudentController.cs

@@ -76,7 +76,7 @@ namespace TEAMModelOS.Controllers
                         //id pw name classId no year
                         //retrun 如果有重複則回{ existNo } , 成功則{ id, name, year, classId, no }
                         var importStuds = request.GetProperty("students").EnumerateArray();
-                        Dictionary<string, ListChange> dictChange = new Dictionary<string, ListChange>();
+                        Dictionary<string, GroupChange> dictChange = new Dictionary<string, GroupChange>();
                         while (importStuds.MoveNext())
                         {
                             JsonElement currStud = importStuds.Current;
@@ -102,28 +102,28 @@ namespace TEAMModelOS.Controllers
                                 if (dictChange.ContainsKey(classId))
                                 {
                                     dictChange[classId].stujoin.Add(
-                                        new Students
+                                        new Member
                                         {
                                             id = id,
-                                            code = $"Base-{schoolId.GetString()}",
-                                            schoolId = schoolId.GetString()
+                                            code = $"{schoolId.GetString()}",
+                                            type=2,
                                         });
                                 }
                                 else {
-                                    ListChange change = new ListChange
+                                    GroupChange change = new GroupChange
                                     {
                                         scope = "school",
                                         school = schoolId.GetString(),
                                         type = "student",
                                         originCode = schoolId.GetString(),
                                         listid = classId,
-                                        stujoin = new List<Students> 
+                                        stujoin = new List<Member> 
                                         { 
-                                            new Students 
+                                            new Member
                                             { 
                                                 id= id,
-                                                code= $"Base-{schoolId.GetString()}",
-                                                schoolId=schoolId.GetString()
+                                                code=schoolId.GetString(),
+                                                type=2,
                                             } 
                                         }
                                     };
@@ -135,7 +135,7 @@ namespace TEAMModelOS.Controllers
                                     if (change.stujoin.Count != 0 || change.stuleave.Count != 0)
                                     {
                                         var messageChange = new ServiceBusMessage(change.ToJsonString());
-                                        messageChange.ApplicationProperties.Add("name", "StuList");
+                                        messageChange.ApplicationProperties.Add("name", "GroupChange");
                                         var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                                         await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                                     }
@@ -313,9 +313,9 @@ namespace TEAMModelOS.Controllers
         /// <param name="opt">操作</param>
         /// <param name="prestudents">变更前的学生</param>
         /// <returns></returns>
-        private async  Task<Dictionary<string, ListChange>> CheckStudent(string  schoolId, List<Student> students , string opt ,List<Student> prestudents) {
+        private async  Task<Dictionary<string, GroupChange>> CheckStudent(string  schoolId, List<Student> students , string opt ,List<Student> prestudents) {
             List<Student> aftstudents=await  GeStudentData(schoolId, students);
-            Dictionary<string, ListChange> dictChange = new Dictionary<string, ListChange>();
+            Dictionary<string, GroupChange> dictChange = new Dictionary<string, GroupChange>();
             if (prestudents.Count >= aftstudents.Count)
             {
                 foreach (var pstu in prestudents)
@@ -329,29 +329,29 @@ namespace TEAMModelOS.Controllers
                             if (dictChange.ContainsKey(afstu.classId))
                             {
                                 dictChange[afstu.classId].stujoin.Add(
-                                new Students
+                                new Member
                                 {
                                     id = afstu.id,
-                                    code = $"Base-{schoolId }",
-                                    schoolId = schoolId 
+                                    code = $"{schoolId }",
+                                    type =2
                                 });
                             }
                             else
                             {
-                                ListChange change = new ListChange
+                                GroupChange change = new GroupChange
                                 {
                                     scope = "school",
                                     school = schoolId ,
                                     type = "student",
                                     originCode = schoolId ,
                                     listid =afstu. classId,
-                                    stujoin = new List<Students>
+                                    stujoin = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= afstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type =2
                                         }
                                     }
                                 };
@@ -364,29 +364,29 @@ namespace TEAMModelOS.Controllers
                             if (dictChange.ContainsKey(pstu.classId))
                             {
                                 dictChange[pstu.classId].stuleave.Add(
-                                new Students
+                                new Member
                                 {
                                     id = pstu.id,
-                                    code = $"Base-{schoolId }",
-                                    schoolId = schoolId
+                                    code = $"{schoolId }",
+                                    type=2
                                 });
                             }
                             else
                             {
-                                ListChange change = new ListChange
+                                GroupChange change = new GroupChange
                                 {
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
                                     originCode = schoolId,
                                     listid = pstu.classId,
-                                    stuleave = new List<Students>
+                                    stuleave = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= pstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type=2
                                         }
                                     }
                                 };
@@ -402,29 +402,29 @@ namespace TEAMModelOS.Controllers
                                 if (dictChange.ContainsKey(afstu.classId))
                                 {
                                     dictChange[afstu.classId].stujoin.Add(
-                                    new Students
+                                    new Member
                                     {
                                         id = afstu.id,
-                                        code = $"Base-{schoolId }",
-                                        schoolId = schoolId
+                                        code = $"{schoolId }",
+                                        type = 2
                                     });
                                 }
                                 else
                                 {
-                                    ListChange change = new ListChange
+                                    GroupChange change = new GroupChange
                                     {
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
                                         originCode = schoolId,
                                         listid = afstu.classId,
-                                        stujoin = new List<Students>
+                                        stujoin = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= afstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type = 2
                                         }
                                     }
                                     };
@@ -433,29 +433,29 @@ namespace TEAMModelOS.Controllers
                                 if (dictChange.ContainsKey(pstu.classId))
                                 {
                                     dictChange[pstu.classId].stuleave.Add(
-                                    new Students
+                                    new Member
                                     {
                                         id = pstu.id,
-                                        code = $"Base-{schoolId }",
-                                        schoolId = schoolId
+                                        code = $"{schoolId }",
+                                        type= 2
                                     });
                                 }
                                 else
                                 {
-                                    ListChange change = new ListChange
+                                    GroupChange change = new GroupChange
                                     {
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
                                         originCode = schoolId,
                                         listid = pstu.classId,
-                                        stuleave = new List<Students>
+                                        stuleave = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= pstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type= 2
                                         }
                                     }
                                     };
@@ -477,29 +477,29 @@ namespace TEAMModelOS.Controllers
                             if (dictChange.ContainsKey(pstu.classId))
                             {
                                 dictChange[pstu.classId].stuleave.Add(
-                                new Students
+                                new Member
                                 {
                                     id = pstu.id,
                                     code = $"Base-{schoolId }",
-                                    schoolId = schoolId
+                                    type = 2
                                 });
                             }
                             else
                             {
-                                ListChange change = new ListChange
+                                GroupChange change = new GroupChange
                                 {
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
                                     originCode = schoolId,
                                     listid = pstu.classId,
-                                    stuleave = new List<Students>
+                                    stuleave = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= pstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type = 2
                                         }
                                     }
                                 };
@@ -521,29 +521,29 @@ namespace TEAMModelOS.Controllers
                             if (dictChange.ContainsKey(afstu.classId))
                             {
                                 dictChange[afstu.classId].stujoin.Add(
-                                new Students
+                                new Member
                                 {
                                     id = afstu.id,
-                                    code = $"Base-{schoolId }",
-                                    schoolId = schoolId
+                                    code = $"{schoolId }",
+                                    type = 2
                                 });
                             }
                             else
                             {
-                                ListChange change = new ListChange
+                                GroupChange change = new GroupChange
                                 {
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
                                     originCode = schoolId,
                                     listid = afstu.classId,
-                                    stujoin = new List<Students>
+                                    stujoin = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= afstu.id,
                                             code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            type = 2
                                         }
                                     }
                                 };
@@ -556,29 +556,29 @@ namespace TEAMModelOS.Controllers
                             if (dictChange.ContainsKey(pstu.classId))
                             {
                                 dictChange[pstu.classId].stuleave.Add(
-                                new Students
+                                new Member
                                 {
                                     id = pstu.id,
-                                    code = $"Base-{schoolId }",
-                                    schoolId = schoolId
+                                    code = $"{schoolId }",
+                                    type= 2
                                 });
                             }
                             else
                             {
-                                ListChange change = new ListChange
+                                GroupChange change = new GroupChange
                                 {
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
                                     originCode = schoolId,
                                     listid = pstu.classId,
-                                    stuleave = new List<Students>
+                                    stuleave = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= pstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type= 2
                                         }
                                     }
                                 };
@@ -594,29 +594,29 @@ namespace TEAMModelOS.Controllers
                                 if (dictChange.ContainsKey(afstu.classId))
                                 {
                                     dictChange[afstu.classId].stujoin.Add(
-                                    new Students
+                                    new Member
                                     {
                                         id = afstu.id,
-                                        code = $"Base-{schoolId }",
-                                        schoolId = schoolId
+                                        code = $"{schoolId }",
+                                        type = 2
                                     });
                                 }
                                 else
                                 {
-                                    ListChange change = new ListChange
+                                    GroupChange change = new GroupChange
                                     {
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
                                         originCode = schoolId,
                                         listid = afstu.classId,
-                                        stujoin = new List<Students>
+                                        stujoin = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= afstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type = 2
                                         }
                                     }
                                     };
@@ -625,29 +625,29 @@ namespace TEAMModelOS.Controllers
                                 if (dictChange.ContainsKey(pstu.classId))
                                 {
                                     dictChange[pstu.classId].stuleave.Add(
-                                    new Students
+                                    new Member
                                     {
                                         id = pstu.id,
-                                        code = $"Base-{schoolId }",
-                                        schoolId = schoolId
+                                        code = $"{schoolId }",
+                                        type=2
                                     });
                                 }
                                 else
                                 {
-                                    ListChange change = new ListChange
+                                    GroupChange change = new GroupChange
                                     {
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
                                         originCode = schoolId,
                                         listid = pstu.classId,
-                                        stuleave = new List<Students>
+                                        stuleave = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= pstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type=2
                                         }
                                     }
                                     };
@@ -671,29 +671,29 @@ namespace TEAMModelOS.Controllers
                             if (dictChange.ContainsKey(afstu.classId))
                             {
                                 dictChange[afstu.classId].stujoin.Add(
-                                new Students
+                                new Member
                                 {
                                     id = afstu.id,
-                                    code = $"Base-{schoolId }",
-                                    schoolId = schoolId
+                                    code = $"{schoolId }",
+                                    type = 2
                                 });
                             }
                             else
                             {
-                                ListChange change = new ListChange
+                                GroupChange change = new GroupChange
                                 {
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
                                     originCode = schoolId,
                                     listid = afstu.classId,
-                                    stujoin = new List<Students>
+                                    stujoin = new List<Member>
                                     {
-                                        new Students
+                                        new Member
                                         {
                                             id= afstu.id,
-                                            code= $"Base-{schoolId}",
-                                            schoolId=schoolId
+                                            code= $"{schoolId}",
+                                            type = 2
                                         }
                                     }
                                 };
@@ -708,7 +708,7 @@ namespace TEAMModelOS.Controllers
                 if ( change.stujoin.Count != 0 || change.stuleave.Count != 0)
                 {
                     var messageChange = new ServiceBusMessage(change.ToJsonString());
-                    messageChange.ApplicationProperties.Add("name", "StuList");
+                    messageChange.ApplicationProperties.Add("name", "GroupChange");
                     var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                     await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                 }
@@ -1610,8 +1610,8 @@ namespace TEAMModelOS.Controllers
             try
             {
                 var exceptions = new List<Exception>();
-                List<StuList> scStuLists = new List<StuList>();
-                List<StuList> teStuLists = new List<StuList>();
+                List<GroupList> scStuLists = new List<GroupList>();
+                List<GroupList> teStuLists = new List<GroupList>();
                 var container = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
                 while (students.MoveNext())
                 {
@@ -1622,23 +1622,23 @@ namespace TEAMModelOS.Controllers
                         id = student.GetProperty("id").GetString();
                         var ret = await container.DeleteItemStreamAsync(id, new PartitionKey($"Base-{schoolId}"));
                         if (ret.Status == (int)HttpStatusCode.NoContent) sucIds.Add(id);
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 in c.students where A0.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: $"select value(c) from c join A0 in c.members where A0.id = '{id}' and A0.code='{schoolId}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{schoolId}") }))
                         {
                             scStuLists.Add(item);
                         }
-                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c join A0 in  c.students where A0.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                        await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupList>(queryText: $"select value(c) from c join A0 in c.members where A0.id = '{id}' and A0.code='{schoolId}'  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList") }))
                         {
                             teStuLists.Add(item);
                         }
                         if (scStuLists.Count > 0)
                         {
-                            foreach (StuList stuList in scStuLists)
+                            foreach (GroupList stuList in scStuLists)
                             {
-                                for (int j = 0; j < stuList.students.Count; j++)
+                                for (int j = 0; j < stuList.members.Count; j++)
                                 {
-                                    if (id.Equals(stuList.students[j].id))
+                                    if (id.Equals(stuList.members[j].id) && stuList.members[j].code.Equals(schoolId))
                                     {
-                                        stuList.students.RemoveAt(j);
+                                        stuList.members.RemoveAt(j);
                                         break;
                                     }
                                 }
@@ -1647,13 +1647,13 @@ namespace TEAMModelOS.Controllers
                         }
                         if (teStuLists.Count > 0)
                         {
-                            foreach (StuList stuList in teStuLists)
+                            foreach (GroupList stuList in teStuLists)
                             {
-                                for (int j = 0; j < stuList.students.Count; j++)
+                                for (int j = 0; j < stuList.members.Count; j++)
                                 {
-                                    if (id.Equals(stuList.students[j].id))
+                                    if (id.Equals(stuList.members[j].id) && stuList.members[j].code.Equals(schoolId))
                                     {
-                                        stuList.students.RemoveAt(j);
+                                        stuList.members.RemoveAt(j);
                                         break;
                                     }
                                 }
@@ -2454,8 +2454,8 @@ namespace TEAMModelOS.Controllers
                         }
                         //取得該學生跑班課名單ID
                         List<string> stulistidsSch = new List<string>();
-                        var querysl = $"SELECT c.id FROM c JOIN students IN c.students WHERE students.id = '{id.GetString()}' AND students.code = 'Base-{school_code}'";
-                        await foreach (var item in schoolClient.GetItemQueryStreamIterator(queryText: querysl, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{school_code}") }))
+                        var querysl = $"SELECT c.id FROM c JOIN members IN c.members WHERE members.id = '{id.GetString()}' AND members.code = '{school_code}'";
+                        await foreach (var item in schoolClient.GetItemQueryStreamIterator(queryText: querysl, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school_code}") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
                             if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -2482,8 +2482,8 @@ namespace TEAMModelOS.Controllers
                         ////個人
                         //取得該學生跑班課名單ID
                         Dictionary<string, Dictionary<string, string>> stulistidsTea = new Dictionary<string, Dictionary<string, string>>();
-                        var queryslt = $"SELECT c.id, c.course.id as courseId, c.course.code as courseCode FROM c JOIN students IN c.students WHERE students.id = '{id.GetString()}' AND students.code = 'Base-{school_code}'";
-                        await foreach (var item in teacherClient.GetItemQueryStreamIterator(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("StuList") }))
+                        var queryslt = $"SELECT c.id, c.course.id as courseId, c.course.code as courseCode FROM c JOIN members IN c.members WHERE members.id = '{id.GetString()}' AND members.code = '{school_code}'";
+                        await foreach (var item in teacherClient.GetItemQueryStreamIterator(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("GroupList") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
                             var js = json.RootElement.ToJsonString();