Jelajahi Sumber

调整名单。

CrazyIter_Bin 3 tahun lalu
induk
melakukan
05ca9d867e

+ 4 - 3
TEAMModelOS.SDK/Models/Cosmos/Common/GroupList.cs

@@ -233,8 +233,8 @@ namespace TEAMModelOS.SDK.Models
     {
         public string scope { get; set; }
 
-        public IdName subject { get; set; }
-        public IdName period { get; set; }
+        public IdNameCode subject { get; set; }
+        public IdNameCode period { get; set; }
         public string name { get; set; }
         public string id { get; set; }
         public TeachSchedule schedule { get; set; }
@@ -245,9 +245,10 @@ namespace TEAMModelOS.SDK.Models
         public string stulist { get; set; }
         public string teacherId { get; set; }
     }
-    public class IdName
+    public class IdNameCode
     {
         public string id { get; set; }
         public string name { get; set; }
+        public string code { get; set; }
     }
 }

+ 22 - 3
TEAMModelOS/Controllers/School/SchoolTeacherController.cs

@@ -69,7 +69,25 @@ namespace TEAMModelOS.Controllers
                 }
                 teachers.Add(item);
             }
-
+          
+            if (teachers.IsNotEmpty()) {
+                List<IdNameCode> groupLists = new List<IdNameCode>();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdNameCode>
+                    (queryText: $"SELECT c.id, c.name, m.id as code  FROM c join m in c.members  where  c.type='research' and m.id in ({string.Join(",",teachers.Select(x=>$"'{x.id}'"))}) ", 
+                    requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school_code}") }))
+                {
+                    groupLists.Add(item);
+                }
+                if (groupLists.IsNotEmpty()) {
+                    teachers.ForEach(x => {
+                        List<IdNameCode> codes = groupLists.FindAll(g => g.code.Equals(x.id));
+                        if (codes.IsNotEmpty())
+                        {
+                            x.groups = codes;
+                        }
+                    });
+                }
+            }
             return Ok(new { teachers });
         }
         public class ScTeacher
@@ -84,8 +102,9 @@ namespace TEAMModelOS.Controllers
             public int size { get; set; }
             public List<string> permissions { get; set; }
             public List<string> roles { get; set; }
-        
-        }
+            public List<IdNameCode> groups { get; set; } = new List<IdNameCode>();
+
+    }
         /// <summary>
         /// 取得某位老師的權限
         /// </summary>