Browse Source

扫码加入名单

CrazyIter_Bin 3 năm trước cách đây
mục cha
commit
c2b267dda6

+ 1 - 1
TEAMModelFunction/MonitorServicesBus.cs

@@ -273,7 +273,7 @@ namespace TEAMModelFunction
             var client = _azureCosmos.GetCosmosClient();
             try
             {
-                await _dingDing.SendBotMsg($"ServiceBus,StuList:{msg}", GroupNames.醍摩豆服務運維群組);
+              
                 var jsonMsg = JsonDocument.Parse(msg);
                 StuListChange stuListChange = msg.ToObject<StuListChange>();
                 //名单变动修改学生课程关联信息

+ 4 - 2
TEAMModelOS.SDK/Models/Service/StuListService.cs

@@ -178,7 +178,8 @@ namespace TEAMModelFunction
                         scope = course.scope,
                         school = course.school,
                         creatorId = course.creatorId,
-                        pk = "StuCourse"
+                        pk = "StuCourse",
+                        stulist = new List<string> { stuListChange.listid }
                     };
                     await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-StuListService-FixStuCourse\n名单发生变更 新建课程中间表\n{stucourse.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                     await client.GetContainer("TEAMModelOS", "Student").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
@@ -195,7 +196,8 @@ namespace TEAMModelFunction
                         scope = course.scope,
                         school = course.school,
                         creatorId = course.creatorId,
-                        pk = "StuCourse"
+                        pk = "StuCourse",
+                        stulist= new List<string> { stuListChange .listid}
                     };
                     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));

+ 74 - 0
TEAMModelOS/Controllers/School/CourseController.cs

@@ -238,6 +238,80 @@ namespace TEAMModelOS.Controllers
         }
             
          */
+        /// <summary>
+        /// 扫码加入名单
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("scan-code-join-list")]
+        public async Task<IActionResult> ScanCodeJoinList(JsonElement json)
+        {
+            try
+            {
+
+                if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
+                if (!json.TryGetProperty("userid", out JsonElement _userid)) return BadRequest();
+                json.TryGetProperty("school", out JsonElement _school);
+                string userid = $"{_userid}";
+                string school = $"{_school}";
+                var client = _azureCosmos.GetCosmosClient();
+                var queryNo = $"SELECT  *  FROM c where  c.no ='{_stuListNo}'";
+                StuList stuList = null;
+                json.TryGetProperty("studentId", out JsonElement _studentId);
+                json.TryGetProperty("tmdId", out JsonElement _tmdId);
+                if (!string.IsNullOrEmpty(school))
+                {
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
+                          requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
+                    {
+                        using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
+                        if (jsonNo.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                        {
+                            var stuDoc = jsonNo.RootElement.GetProperty("Documents").EnumerateArray();
+                            while (stuDoc.MoveNext())
+                            {
+                                JsonElement data = stuDoc.Current;
+                                stuList = data.ToObject<StuList>();
+                                if (stuList != null)
+                                {
+                                    (int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
+                                    stuLis = await upsertList(stuList, "school");
+                                    return Ok(new { status, stuLis });
+                                }
+                            }
+                        }
+                    }
+                }
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
+                    requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
+                {
+                    using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (jsonNo.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        var stuDoc = jsonNo.RootElement.GetProperty("Documents").EnumerateArray();
+                        while (stuDoc.MoveNext())
+                        {
+                            JsonElement data = stuDoc.Current;
+                            stuList = data.ToObject<StuList>();
+                            if (stuList != null)
+                            {
+                                (int status, StuList stuLis) = JoinList(stuList, $"{_studentId}", $"{_tmdId}", school);
+                                stuLis = await upsertList(stuList, "private");
+                                return Ok(new { status, stuLis });
+                            }
+                        }
+                    }
+                }
+                return Ok(new { status = -1 });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},course/get-list-by-no()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+
 
         /// <summary>
         /// 根据邀请码加入名单

+ 4 - 5
TEAMModelOS/TEAMModelOS.csproj

@@ -37,11 +37,10 @@
     <SpaRoot>ClientApp\</SpaRoot>
     <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
     <UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-    <Version>5.2107.21</Version>
-    <AssemblyVersion>5.2107.21.1</AssemblyVersion>
-    <FileVersion>5.2107.20.3</FileVersion>
-    <Description>1.HiTeach API :掃碼加入學生相關處理
-2.字串檔變更</Description>
+    <Version>5.2107.26</Version>
+    <AssemblyVersion>5.2107.26.1</AssemblyVersion>
+    <FileVersion>5.2107.26.1</FileVersion>
+    <Description>修复学生端扫码加入课程名单,联动触发相关课程和活动。</Description>
     <PackageReleaseNotes>版本说明</PackageReleaseNotes>
   </PropertyGroup>
   <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">