zhouj1203@hotmail.com 2 年之前
父節點
當前提交
42cdd94d97
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. 1 0
      TEAMModelOS.SDK/Models/Cosmos/Student/ErrorItems.cs
  2. 14 1
      TEAMModelOS/Controllers/Common/ExamController.cs

File diff suppressed because it is too large
+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Student/ErrorItems.cs


+ 14 - 1
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -3475,6 +3475,19 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 //var queryTeacher = $"select value(c) from c where c.stuId = '{stuId}' and c.school = '{code}' and c.subjectId = '{subjectId}'";
                 List<ErrorItems> errorItems = new();
+                List<string> ids = new();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select A0.id from c join A0 in c.its where c.stuId = '{stuId}' and c.subjectId = '{subjectId}' ", requestOptions: new QueryRequestOptions() {PartitionKey = new PartitionKey($"{pk}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            ids.Add(obj.GetProperty("id").ToString());
+                        }
+                    }
+                    
+                }
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: token, requestOptions: new QueryRequestOptions() {MaxItemCount = topcout, PartitionKey = new PartitionKey($"{pk}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -3491,7 +3504,7 @@ namespace TEAMModelOS.Controllers
                         break;
                     }
                 }
-                return Ok(new { errorItems, token });
+                return Ok(new { errorItems, token, ids.Count });
             }
             catch (Exception ex)
             {