Prechádzať zdrojové kódy

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

CrazyIter_Bin 3 rokov pred
rodič
commit
e9765200e7

+ 19 - 3
TEAMModelOS/Controllers/School/StudentController.cs

@@ -11,6 +11,7 @@ using System.Threading.Tasks;
 using Azure;
 using Azure.Cosmos;
 using Azure.Storage.Sas;
+using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Cryptography.KeyDerivation;
 using Microsoft.AspNetCore.Mvc;
@@ -1957,9 +1958,11 @@ namespace TEAMModelOS.Controllers
             try
             {
                 if (!requert.TryGetProperty("students", out JsonElement students)) return BadRequest();
-                //if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
+                if (!requert.TryGetProperty("tmdIds", out JsonElement tmdIds)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 List<Students> stuList = students.ToObject<List<Students>>();
+                List<string> tmdids = tmdIds.ToObject<List<string>>();
+                List<TmdInfo> tmdinfos = new List<TmdInfo>();
                 List<object> stus = new List<object>();               
                 foreach (Students stu in stuList) {
                     var query = $"select c.id,c.name,c.picture,c.classId,c.code,c.groupId,c.groupName,c.no from c where c.id = '{stu.id}'";
@@ -1974,8 +1977,21 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }
-                }              
-                return Ok(new { stus });
+                }
+                if (tmdids.IsNotEmpty())
+                {
+                    
+                    List<string> inids = new List<string>();
+                    tmdids.ForEach(x => { inids.Add($"'{x}'"); });
+                    var insql = string.Join(",", inids);
+                    var queryslt = $"SELECT  value(c) FROM c where c.id in ({insql})";
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                    {
+                        tmdinfos.Add(item);
+                    }
+                    //tmdinfos.AddRange(infos);
+                }
+                return Ok(new { stus, tmdinfos });
             }
             catch (Exception ex)
             {