|
@@ -15,6 +15,8 @@ using Microsoft.Extensions.Options;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using TEAMModelOS.Filter;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
+using System.Linq;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -30,8 +32,9 @@ namespace TEAMModelOS.Controllers
|
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
|
private readonly DingDing _dingDing;
|
|
|
private readonly Option _option;
|
|
|
- private readonly IConfiguration _configuration;
|
|
|
- public SchoolSettingController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
|
|
|
+ private readonly IConfiguration _configuration;
|
|
|
+ private readonly HttpTrigger _httpTrigger;
|
|
|
+ public SchoolSettingController(HttpTrigger httpTrigger, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_azureStorage = azureStorage;
|
|
@@ -39,6 +42,7 @@ namespace TEAMModelOS.Controllers
|
|
|
_dingDing = dingDing;
|
|
|
_option = option?.Value;
|
|
|
_configuration = configuration;
|
|
|
+ _httpTrigger = httpTrigger;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -138,6 +142,23 @@ namespace TEAMModelOS.Controllers
|
|
|
case bool when $"{_opt}".Equals("UpsertLessonTag", StringComparison.OrdinalIgnoreCase) && (json.TryGetProperty("lessonTag", out JsonElement _lessonTag)):
|
|
|
HashSet <string> lessonTag = _lessonTag.ToObject<HashSet<string>>();
|
|
|
setting.lessonTag = lessonTag;
|
|
|
+ List<TagOldNew> old_new = null;
|
|
|
+ if (json.TryGetProperty("old_new", out JsonElement _old_new))
|
|
|
+ {
|
|
|
+ old_new = _old_new.ToObject<List<TagOldNew>>();
|
|
|
+ }
|
|
|
+ //处理标签删除的问题。
|
|
|
+ if (old_new.IsNotEmpty() && lessonTag != null)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ _ = _httpTrigger.RequestHttpTrigger(new { old_new = old_new, school = $"{_school}" }, _option.Location, "lesson-tag-change");
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ //暂不处理
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case bool when $"{_opt}".Equals("UpsertLessonSetting", StringComparison.OrdinalIgnoreCase) && (json.TryGetProperty("lessonSetting", out JsonElement _lessonSetting)):
|
|
|
LessonSetting lessonSetting = _lessonSetting.ToObject<LessonSetting>();
|
|
@@ -145,7 +166,7 @@ namespace TEAMModelOS.Controllers
|
|
|
break;
|
|
|
default: break;
|
|
|
}
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<SchoolSetting>(setting, partitionKey: new Azure.Cosmos.PartitionKey("SchoolSetting"));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolSetting>(setting,setting.id, partitionKey: new Azure.Cosmos.PartitionKey("SchoolSetting"));
|
|
|
return Ok(new { setting });
|
|
|
}
|
|
|
}
|