CrazyIter_Bin 3 lat temu
rodzic
commit
26e0f33d7f

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

@@ -13,13 +13,15 @@ namespace TEAMModelOS.SDK.Models
         //标记该名单唯一code
         public string no { get; set; }
         public string periodId { get; set; }
+        //课程id,需要标记则标记
+        //public string courseId { get; set; }
         public string scope { get; set; }
         public string school { get; set; }
         public string creatorId { get; set; }
         /// <summary>
-        /// 学生名单类型student ,教研组research,学科组subject,好友friend,管理manage,群组group等
+        ///教学班teach ,行政班(学生搜寻classId动态返回)student ,教研组research,学科组(学科搜寻动态返回)subject,好友friend,管理manage,群组group等
         /// </summary>
-        public string type { get; set; } = "student";
+        public string type { get; set; } = "teach";
         public List<Member> members { get; set; } = new List<Member>();
 
     }
@@ -43,6 +45,6 @@ namespace TEAMModelOS.SDK.Models
         /// IRS WebIRS编号。
         /// </summary>
         public string no { get; set; }
-       // public string role { get; set; }
+        public string role { get; set; }
     }
 }

+ 61 - 6
TEAMModelOS/Controllers/School/GroupListController.cs

@@ -24,7 +24,7 @@ namespace TEAMModelOS.Controllers
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
     //[Authorize(Roles = "IES5")]
-    [Route("group-list")]
+    [Route("grouplist")]
     [ApiController]
     public class GroupListController : ControllerBase
     {
@@ -46,7 +46,56 @@ namespace TEAMModelOS.Controllers
         //处理通用名单
         [ProducesDefaultResponseType]
         [AuthToken(Roles = "teacher,admin")]
-        [HttpPost("upsert-group-list")]
+        [HttpPost("get-grouplists")]
+        public async Task<IActionResult> GetGrouplists(JsonElement json)
+        {
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+            }
+            catch (CosmosException)
+            {
+            }
+            return Ok();
+        }
+        //处理通用名单
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "teacher,admin")]
+        [HttpPost("get-grouplist-idcode")]
+        public async Task<IActionResult> GetGrouplistIdcode(JsonElement json) {
+            GroupList groupList = null;
+            try {
+                var client = _azureCosmos.GetCosmosClient();
+                if (!json.TryGetProperty("code", out JsonElement _code)) return BadRequest();
+                if (!json.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
+                if (!json.TryGetProperty("id", out JsonElement id)) return BadRequest();
+                string tbname =  $"{scope}".Equals("private") ? "Teacher" : "School";
+                string code = "";
+                 if (  $"{scope}".Equals("private"))
+                {
+                    //私人名单
+                      code = "GroupList";
+                }
+                else
+                {
+                    //学校自定义名单
+                     code = !code.StartsWith("GroupList-") ? $"GroupList-{code}" : code;
+                }
+                groupList= await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<GroupList>($"{id}", new PartitionKey($"{code}"));
+            } catch (CosmosException) {
+                groupList = null;
+            }
+            return Ok(new { groupList });
+        }
+
+        /// <summary>
+        /// 保存或更新通用名单
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "teacher,admin")]
+        [HttpPost("upsert-grouplist")]
         public async Task<IActionResult> UpsertGroupList(JsonElement json)
         {
             try
@@ -62,8 +111,9 @@ namespace TEAMModelOS.Controllers
                 }
                 GroupList list = _list.ToObject<GroupList>();
                 if (list != null) {
+                    list.ttl = -1;
                     list.creatorId = userid;
-                    list.school = school;
+                    list.school =string.IsNullOrEmpty(list.school)?school: list.school;
                     list.pk = "GroupList";
                     if (list.scope.Equals("private"))
                     {
@@ -77,22 +127,27 @@ namespace TEAMModelOS.Controllers
                     switch (true)
                     {
                         //普通学生名单(包含学校教学班名单,个人课程名单),其中学生成员账号类型可以是学校学生账号和醍摩豆ID,分区键为GroupList-hbcn  分区键为GroupList
-                        case bool when $"{_type}".Equals("student", StringComparison.OrdinalIgnoreCase):
-                            list.type = "student";
+                        case bool when $"{_type}".Equals("teach", StringComparison.OrdinalIgnoreCase):
+                            list.type = "teach";
                             list = await CheckListNo(list);
+                            list = await UpsertList(list);
                             break;
                         //教研组名单,只有加入学校的老师名单 成员账号类型是醍摩豆ID,保存在学校表,分区键为GroupList-hbcn
                         case bool when $"{_type}".Equals("research", StringComparison.OrdinalIgnoreCase):
                             list.type = "research";
+                            list.scope = "school";
+                            list = await UpsertList(list);
                             break;
                         //个人好友名单,成员账号类型可以是学校学生账号和醍摩豆ID,分区键为GroupList
                         case bool when $"{_type}".Equals("friend", StringComparison.OrdinalIgnoreCase):
                             list.type = "friend";
+                            list = await UpsertList(list);
                             break;
                         //社交群组类型(包含学校交流群组,个人交流群组),成员账号类型可以是学校学生账号和醍摩豆ID,,分区键为GroupList-hbcn  分区键为GroupList
                         case bool when $"{_type}".Equals("group", StringComparison.OrdinalIgnoreCase):
                             list.type = "group";
                             list = await CheckListNo(list);
+                            list = await UpsertList(list);
                             break;
                     }
                 }
@@ -114,7 +169,7 @@ namespace TEAMModelOS.Controllers
             string tbname = list.scope.Equals("private") ? "Teacher" : "School";
             await client.GetContainer(Constant.TEAMModelOS, tbname).UpsertItemAsync(list, new PartitionKey(list.code));
             //学生名单,教研组会触发活动中间表刷新
-            if (list.type.Equals("student") || list.type.Equals("research")) {
+            if (list.type.Equals("teach") || list.type.Equals("research")) {
                 GroupChange change = new GroupChange()
                 {
                     type = list.type,