|
@@ -56,12 +56,12 @@ namespace TEAMModelOS.Controllers.Common
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- TeacherWork work = request.ToObject<TeacherWork>();
|
|
|
|
|
|
+ Homework work = request.ToObject<Homework>();
|
|
work.owner = "school";
|
|
work.owner = "school";
|
|
try
|
|
try
|
|
{
|
|
{
|
|
work.ttl = -1;
|
|
work.ttl = -1;
|
|
- work.code = "TeacherWork-" + work.school;
|
|
|
|
|
|
+ work.code = "Homework-" + work.school;
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
work.createTime = now;
|
|
work.createTime = now;
|
|
|
|
|
|
@@ -84,7 +84,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/save()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/save()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -110,11 +110,11 @@ namespace TEAMModelOS.Controllers.Common
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
//List<List<string>> answer = ans.ToObject<List<List<string>>>();
|
|
//List<List<string>> answer = ans.ToObject<List<List<string>>>();
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
- var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"TeacherWork-{code}"));
|
|
|
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Homework-{code}"));
|
|
if (response.Status == (int)HttpStatusCode.OK)
|
|
if (response.Status == (int)HttpStatusCode.OK)
|
|
{
|
|
{
|
|
var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
- TeacherWork work = json.ToObject<TeacherWork>();
|
|
|
|
|
|
+ Homework work = json.ToObject<Homework>();
|
|
//List<List<string>> standard = work.items.answers;
|
|
//List<List<string>> standard = work.items.answers;
|
|
bool flag = work.teachers.Exists(s => s.id.Equals(tId.GetString()));
|
|
bool flag = work.teachers.Exists(s => s.id.Equals(tId.GetString()));
|
|
List<string> ids = work.teachers.Select(e => e.id).ToList();
|
|
List<string> ids = work.teachers.Select(e => e.id).ToList();
|
|
@@ -148,7 +148,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/record-in()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/record-in()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -164,7 +164,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"TeacherWork-{code}"));
|
|
|
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Homework-{code}"));
|
|
return Ok(new { id, code = response.Status });
|
|
return Ok(new { id, code = response.Status });
|
|
|
|
|
|
|
|
|
|
@@ -172,7 +172,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/delete()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/delete()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -209,7 +209,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
|
|
|
|
List<object> works = new();
|
|
List<object> works = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"TeacherWork-{code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Homework-{code}") }))
|
|
{
|
|
{
|
|
|
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -231,7 +231,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/find()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/find()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -247,8 +247,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- List<TeacherWork> works = new();
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<TeacherWork>(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherWork-{code}") }))
|
|
|
|
|
|
+ List<Homework> works = new();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Homework>(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
|
|
{
|
|
{
|
|
works.Add(item);
|
|
works.Add(item);
|
|
}
|
|
}
|
|
@@ -256,7 +256,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/FindSummary()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/FindSummary()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -277,7 +277,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var query = $"select c.id,c.name,c.createTime,A0.time from c join A0 in c.teachers where A0.id = '{tId}'";
|
|
var query = $"select c.id,c.name,c.createTime,A0.time from c join A0 in c.teachers where A0.id = '{tId}'";
|
|
List<object> works = new();
|
|
List<object> works = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherWork-{code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
|
|
{
|
|
{
|
|
|
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -293,7 +293,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/find-by-teacher()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/find-by-teacher()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -311,7 +311,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
List<object> works = new();
|
|
List<object> works = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherWork-{code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -326,7 +326,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},TeacherWork/find-summary-by-teacher()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},Homework/find-summary-by-teacher()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|