|
@@ -82,6 +82,54 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
|
|
|
var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
var json = JsonDocument.Parse(data).RootElement;
|
|
|
+ List<TagOldNew> old_new = null;
|
|
|
+ string school = null;
|
|
|
+ if (json.TryGetProperty("school", out JsonElement _school))
|
|
|
+ {
|
|
|
+ school = _school.GetString();
|
|
|
+ }
|
|
|
+ if (json.TryGetProperty("old_new", out JsonElement _old_new))
|
|
|
+ {
|
|
|
+ old_new = _old_new.ToObject<List<TagOldNew>>();
|
|
|
+ }
|
|
|
+ if (old_new.IsNotEmpty() && !string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ foreach (var on in old_new)
|
|
|
+ {
|
|
|
+ List<LessonRecord> lessonRecords = new List<LessonRecord>();
|
|
|
+ string sql = $"select value(c) from c where array_contains(c.category,'{on._old}') ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonRecord>
|
|
|
+ (queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{_school}") }))
|
|
|
+ {
|
|
|
+ lessonRecords.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ lessonRecords.ForEach(item =>
|
|
|
+ {
|
|
|
+ //修改知识点
|
|
|
+ if (!string.IsNullOrEmpty(on._new))
|
|
|
+ {
|
|
|
+ for (int i = 0; i < item.category.Count; i++)
|
|
|
+ {
|
|
|
+ if (item.category[i].Equals(on._old))
|
|
|
+ {
|
|
|
+ item.category[i] = on._new;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //表示删除知识点
|
|
|
+ item.category.RemoveAll(x => x.Equals(on._old));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ foreach (var item in lessonRecords)
|
|
|
+ {
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await response.WriteAsJsonAsync(new { data = json });
|
|
|
return response;
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -96,7 +144,7 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
|
|
|
var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
var json = JsonDocument.Parse(data).RootElement;
|
|
|
- List<KnowledgeOldNew> old_new = null;
|
|
|
+ List<TagOldNew> old_new = null;
|
|
|
string school = null;
|
|
|
if (json.TryGetProperty("school", out JsonElement _school))
|
|
|
{
|
|
@@ -104,7 +152,7 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
|
|
|
}
|
|
|
if (json.TryGetProperty("old_new", out JsonElement _old_new))
|
|
|
{
|
|
|
- old_new = _old_new.ToObject<List<KnowledgeOldNew>>();
|
|
|
+ old_new = _old_new.ToObject<List<TagOldNew>>();
|
|
|
}
|
|
|
if (old_new.IsNotEmpty() && !string.IsNullOrWhiteSpace(school))
|
|
|
{
|