|
@@ -387,14 +387,16 @@ namespace TEAMModelOS.Controllers
|
|
|
[ProducesDefaultResponseType]
|
|
|
//[AuthToken(Roles = "teacher,admin")]
|
|
|
[HttpPost("save-art")]
|
|
|
- [Authorize(Roles = "IES")]
|
|
|
+ //[Authorize(Roles = "IES")]
|
|
|
public async Task<IActionResult> SaveArt(JsonElement request)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!request.TryGetProperty("art", out JsonElement art)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("artExam", out JsonElement artExam)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
+ List<ArtExam> am = artExam.ToObject<List<ArtExam>>();
|
|
|
var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
//获取区级以下所有学校编码和基础信息
|
|
|
List<string> baseIds = new();
|
|
@@ -425,7 +427,12 @@ namespace TEAMModelOS.Controllers
|
|
|
if (string.IsNullOrEmpty(areaArt.id))
|
|
|
{
|
|
|
areaArt.id = Guid.NewGuid().ToString();
|
|
|
- }
|
|
|
+ }
|
|
|
+ foreach (var aExam in am) {
|
|
|
+ aExam.id = Guid.NewGuid().ToString();
|
|
|
+ aExam.activityId = areaArt.id;
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(aExam, new PartitionKey("{ArtExam}"));
|
|
|
+ }
|
|
|
foreach (string scId in baseIds)
|
|
|
{
|
|
|
ArtEvaluation ae = art.ToObject<ArtEvaluation>();
|
|
@@ -562,8 +569,25 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
//区级id
|
|
|
if (!request.TryGetProperty("areaId", out JsonElement code)) return BadRequest();
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ List<string> ide = new();
|
|
|
var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Art-{code}"));
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id,c.code from c where c.activityId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ArtExam") }))
|
|
|
+ {
|
|
|
+
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ ide.Add(account.GetProperty("id").GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").DeleteItemsAsync<ArtExam>(ide, "ArtExam");
|
|
|
List<(string id, string name)> bascId = await getId(client, code.GetString());
|
|
|
List<(string id, string name)> ids = new();
|
|
|
foreach ((string sId, string name) in bascId)
|