|
@@ -40,7 +40,8 @@ namespace TEAMModelAPI.Controllers
|
|
|
private readonly Option _option;
|
|
|
private readonly IConfiguration _configuration;
|
|
|
private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
- public GroupListController(CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
|
|
|
+ private readonly AzureServiceBusFactory _serviceBus;
|
|
|
+ public GroupListController(CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, AzureServiceBusFactory serviceBus)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_azureStorage = azureStorage;
|
|
@@ -49,6 +50,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
_option = option?.Value;
|
|
|
_configuration = configuration;
|
|
|
_coreAPIHttpService = coreAPIHttpService;
|
|
|
+ _serviceBus = serviceBus;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -181,7 +183,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
public async Task<IActionResult> ImportClassMembers(JsonElement json)
|
|
|
{
|
|
|
var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
- if (!json.TryGetProperty("periodId", out JsonElement _periodId)) { return Ok(new { error = 1, msg = "学段信息错误!" }); }
|
|
|
+ if (!json.TryGetProperty("periodId", out JsonElement _periodId)) { return Ok(new { error = 2, msg = "学段信息错误!" }); }
|
|
|
if (json.TryGetProperty("students", out JsonElement _students)) { return Ok(new { error = 1, msg = "学生列表格式错误!" }); }
|
|
|
if (_students.ValueKind.Equals(JsonValueKind.Array))
|
|
|
{
|
|
@@ -190,17 +192,19 @@ namespace TEAMModelAPI.Controllers
|
|
|
if (period != null)
|
|
|
{
|
|
|
List<Student> webStudents = _students.ToObject<List<Student>>();
|
|
|
+ List<Student> preStudents = await StudentService.GeStudentData(_azureCosmos, school, webStudents);
|
|
|
+ var retUpsert = await StudentService.upsertStudents(_azureCosmos, _dingDing, _option, school, json.GetProperty("students").EnumerateArray());
|
|
|
+ await StudentService.CheckStudent(_serviceBus, _configuration, _azureCosmos, school, webStudents, preStudents);
|
|
|
+ return this.Ok(new { code = $"Base-{school}", students = retUpsert.studs, retUpsert.classDuplNos, retUpsert.errorIds });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return Ok(new { error = 1, msg = "学段信息错误!" });
|
|
|
+ return Ok(new { error = 2, msg = "学段信息错误!" });
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
return Ok(new { error = 1, msg = "学生列表格式错误" });
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
return Ok();
|
|
|
}
|
|
|
|