Browse Source

教师查询自己的阅卷任务/

CrazyIter_Bin 4 years ago
parent
commit
80bda11d5f
1 changed files with 32 additions and 1 deletions
  1. 32 1
      TEAMModelOS/Controllers/School/CorrectController.cs

+ 32 - 1
TEAMModelOS/Controllers/School/CorrectController.cs

@@ -53,8 +53,39 @@ namespace TEAMModelOS.Controllers
             _azureRedis = azureRedis;
             _azureStorage = azureStorage;
         }
+
+        ///<summary>
+        ///查询教师的阅卷任务列表
+        /// </summary>
+        /// <data>
+        ///    ! "code":"tmdid"
+        /// </data>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("find-task")]
+        public async Task<IActionResult> FindTask(JsonElement requert) {
+            List<CorrectTask> tasks = new List<CorrectTask>();
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+                
+                //活动分区
+                if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<CorrectTask>(queryText: $"select value(c) from c ",
+                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"CorrectTask-{code}") }))
+                {
+                    tasks.Add(item);
+                }
+                return Ok(new { tasks = tasks });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},common/Correct/find-task()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return Ok(new { tasks = tasks });
+            }
+        }
         /*
-         
         {
             "id":"uuid",//新增为null或者空
             "code":"hbcn",