CrazyIter_Bin 1 năm trước cách đây
mục cha
commit
3076ab750e

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

@@ -240,7 +240,7 @@ namespace TEAMModelOS.SDK
         /// <param name="type"></param>
         /// <param name="school"></param>
         /// <returns></returns>
-        public static async Task<(int status, GroupList stuList,Member member)> CodeJoinList(CosmosClient client,AzureRedisFactory _azureRedis, string _stuListNo, string userid, int type, string school,int year,string name ,string picture,string lang,string courseId= null)
+        public static async Task<(int status, GroupList stuList,Member member)> CodeJoinList(CosmosClient client,AzureRedisFactory _azureRedis, string _stuListNo, string userid, int type, string school,int year,string name ,string picture,string lang,int seatNo, string courseId= null)
         {
             var queryNo = $"SELECT  value(c)  FROM c where  c.no ='{_stuListNo}'";
             (int status, GroupList stuList,Member member) data = (-1, null,null);
@@ -249,7 +249,7 @@ namespace TEAMModelOS.SDK
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryNo,
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
                 {
-                    data = JoinList(item, userid, type, school,year);
+                    data = JoinList(item, userid, type, school,year,seatNo);
                     break;
                 }
             }
@@ -343,7 +343,7 @@ namespace TEAMModelOS.SDK
             public int status { get; set; } = -1;
            public List<IdName> courses  { get; set; }= new List<IdName>();
         }
-        public static (int status, GroupList stuList, Member member) JoinList(GroupList stuList, string userid, int type, string school,int year)
+        public static (int status, GroupList stuList, Member member) JoinList(GroupList stuList, string userid, int type, string school, int year, int seatNo = 0)
         {
             int status = -1;
             if (!string.IsNullOrWhiteSpace(stuList.school) && !string.IsNullOrWhiteSpace(school))

+ 41 - 17
TEAMModelOS/Controllers/Both/GroupListController.cs

@@ -14,28 +14,15 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using Azure;
-using TEAMModelOS.SDK.Models.Cosmos.Common;
-using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using TEAMModelOS.Filter;
 using HTEXLib.COMM.Helpers;
 using System.Text;
 using Microsoft.AspNetCore.Authorization;
-using Microsoft.Extensions.Hosting;
-using OpenXmlPowerTools;
-using TEAMModelOS.SDK.Models.Dtos;
 using Microsoft.AspNetCore.Hosting;
-using Azure.Core;
-using static TEAMModelOS.SDK.Services.ActivityStudentService;
 using static TEAMModelOS.SDK.GroupListService;
 using TEAMModelOS.Controllers.Both;
 using CourseDto = TEAMModelOS.Controllers.Both.CourseDto;
-using DocumentFormat.OpenXml.Drawing.Charts;
-using Grpc.Core;
-using Org.BouncyCastle.Asn1.Ocsp;
-using DocumentFormat.OpenXml.Office2010.Excel;
-using System.Security.Claims;
-using TEAMModelOS.Controllers.Analysis;
 
 namespace TEAMModelOS.Controllers
 {
@@ -105,8 +92,40 @@ namespace TEAMModelOS.Controllers
            
             return Ok(new { groups = groups });
         }
-
-
+        [ProducesDefaultResponseType]
+        [HttpPost("get-grouplist-nos")]
+        public async Task<IActionResult> GetGroupListNos(JsonElement json)
+        {
+            GroupList groupList = null;
+            var client = _azureCosmos.GetCosmosClient();
+            if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
+            json.TryGetProperty("school", out JsonElement school);
+            var queryNo = $"SELECT  value(c)  FROM c where  c.no ='{_stuListNo}'";
+            if (!string.IsNullOrEmpty($"{school}"))
+            {
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryNo,
+                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
+                {
+                    groupList=item;
+                    break;
+                }
+            }
+            if (groupList==null) {
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupList>(queryText: queryNo,
+                              requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
+                {
+                    groupList=item;
+                    break;
+                }
+            }
+            if (groupList!=null)
+            {
+                return Ok(new {code=200, nos = groupList.members.Select(x => x.no),optNo= groupList.optNo });
+            }
+            else {
+                return Ok(new {code=404,  nos =new List<string>() , optNo =0});
+            }
+        }
 
         /// <summary>
         /// 扫码加入名单
@@ -120,6 +139,10 @@ namespace TEAMModelOS.Controllers
             if (!json.TryGetProperty("stuListNo", out JsonElement _stuListNo)) return BadRequest();
             json.TryGetProperty("school", out JsonElement school);
             json.TryGetProperty("courseId", out JsonElement _courseId);
+            int seatNo = 0;
+            if (json.TryGetProperty("seatNo", out JsonElement _seatNo)  &&  int.TryParse($"{_seatNo}", out seatNo)) { 
+
+            }
             var client = _azureCosmos.GetCosmosClient();
             json.TryGetProperty("id_token", out JsonElement id_token);
             var jwt = new JwtSecurityToken(id_token.GetString());
@@ -153,7 +176,7 @@ namespace TEAMModelOS.Controllers
                 }
             }
             int year = DateTimeOffset.UtcNow.Year;
-            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", id, type: 1, $"{school}", year, $"{name}", $"{picture}", $"{lang}",$"{_courseId}");
+            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", id, type: 1, $"{school}", year, $"{name}", $"{picture}", $"{lang}", seatNo, $"{_courseId}");
             //没有TmdUser时
             if (data.status == 0)
             {
@@ -236,7 +259,8 @@ namespace TEAMModelOS.Controllers
             {
                 type = 1;
             }
-            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", userid, type, school, year, _name, _picture, head_lang);
+            int seatNo =0;
+            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", userid, type, school, year, _name, _picture, head_lang,seatNo);
             if (data.status == 0)
             {