|
@@ -36,13 +36,15 @@ namespace TEAMModelOS.Controllers
|
|
|
private readonly DingDing _dingDing;
|
|
|
private readonly Option _option;
|
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
|
- public KnowledgesController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis)
|
|
|
+ private readonly HttpTrigger _httpTrigger;
|
|
|
+ public KnowledgesController(HttpTrigger httpTrigger, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_snowflakeId = snowflakeId;
|
|
|
_dingDing = dingDing;
|
|
|
_option = option?.Value;
|
|
|
_azureRedis = azureRedis;
|
|
|
+ _httpTrigger = httpTrigger;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -111,12 +113,12 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(knowledge);
|
|
|
}
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [HttpPost("upserta")]
|
|
|
+ [HttpPost("upsert-knowledge")]
|
|
|
[Authorize(Roles = "IES")]
|
|
|
[AuthToken(Roles = "admin", Permissions = "knowledge-upd")]
|
|
|
- public async Task<IActionResult> UpsertA(JsonElement json)
|
|
|
+ public async Task<IActionResult> UpsertKnowledge(JsonElement json)
|
|
|
{
|
|
|
-
|
|
|
+ if (!json.TryGetProperty("school", out JsonElement school)) return BadRequest();
|
|
|
Knowledge knowledge = json.GetProperty("knowledge").ToObject<Knowledge>();
|
|
|
List<OldNew> old_new = null;
|
|
|
if (json.TryGetProperty("old_new", out JsonElement _old_new))
|
|
@@ -158,12 +160,15 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
return BadRequest($"{notinold.ToJsonString()} 不存在原来的知识点中");
|
|
|
}
|
|
|
- var _new = old_new.Select(x => x._new).ToList();
|
|
|
- var notinnew = _old.Except(knowledge.points);
|
|
|
- if (notinnew != null && notinnew.Count() > 0)
|
|
|
- {
|
|
|
- return BadRequest($"{notinnew.ToJsonString()} 不存在新的知识点中");
|
|
|
+ var _new= old_new.Select(x => x._new).Where(z => !string.IsNullOrEmpty(z));
|
|
|
+ if (_new != null && _new.Count() > 0) {
|
|
|
+ var notinnew = _new.Except(knowledge.points);
|
|
|
+ if (notinnew != null && notinnew.Count() > 0)
|
|
|
+ {
|
|
|
+ return BadRequest($"{notinnew.ToJsonString()} 不存在新的知识点中");
|
|
|
+ }
|
|
|
}
|
|
|
+ _ = _httpTrigger.RequestHttpTrigger(new { old_new = old_new, school = $"{school}" }, _option.Location, "KnowledgeChange");
|
|
|
}
|
|
|
return Ok(knowledge);
|
|
|
}
|