|
@@ -104,6 +104,41 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
|
|
|
}
|
|
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "teacher,admin,student")]
|
|
|
+ [HttpPost("upload")]
|
|
|
+ [Authorize(Roles = "IES")]
|
|
|
+ public async Task<IActionResult> Upload(ArtRecord request)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ request.school = school;
|
|
|
+ request.stuId = userid;
|
|
|
+ request.code = "ArtRecord";
|
|
|
+ long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ request.createTime = now;
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(request.id))
|
|
|
+ {
|
|
|
+ request.id = Guid.NewGuid().ToString();
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
|
+ }
|
|
|
+ return Ok(new { request });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},art/save()\n{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return Ok(new { code = 500, msg = ex.Message });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
[ProducesDefaultResponseType]
|
|
|
[AuthToken(Roles = "teacher,admin")]
|
|
|
[HttpPost("delete")]
|