Browse Source

手动结束

zhouj1203@hotmail.com 4 years ago
parent
commit
30a002a7c9
1 changed files with 27 additions and 0 deletions
  1. 27 0
      TEAMModelOS/Controllers/Common/ExamController.cs

+ 27 - 0
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -872,5 +872,32 @@ namespace TEAMModelOS.Controllers
             }
 
         }
+
+
+        //查询学生活动列表
+        [ProducesDefaultResponseType]
+        //[AuthToken(Roles = "Student")]
+        [HttpPost("finish")]
+        public async Task<IActionResult> finish(JsonElement requert)
+        {
+            //ResponseBuilder builder = ResponseBuilder.custom();
+            //var (id, school) = HttpContext.GetAuthTokenInfo();
+            try
+            {
+                if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
+                if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
+                var client = _azureCosmos.GetCosmosClient();
+                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                info.progress = "finish";
+                info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
+                return Ok(info);
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/finish\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+
+        }
     }
 }