|
@@ -0,0 +1,81 @@
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
+using Microsoft.AspNetCore.Hosting;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.Filter;
|
|
|
+using TEAMModelOS.Models;
|
|
|
+using TEAMModelOS.SDK;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
+using TEAMModelOS.SDK.Extension;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.School;
|
|
|
+
|
|
|
+namespace TEAMModelOS.Controllers.School
|
|
|
+{
|
|
|
+ [ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
+
|
|
|
+ [Route("school/exam")]
|
|
|
+ [ApiController]
|
|
|
+ public class ImportExamController: ControllerBase
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ public IWebHostEnvironment _environment { get; set; }
|
|
|
+ private readonly AzureCosmosFactory _azureCosmos;
|
|
|
+ private readonly SnowflakeId _snowflakeId;
|
|
|
+ private readonly AzureServiceBusFactory _serviceBus;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly Option _option;
|
|
|
+ private readonly AzureStorageFactory _azureStorage;
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
+ public IConfiguration _configuration { get; set; }
|
|
|
+ private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
+ private readonly HttpTrigger _httpTrigger;
|
|
|
+ public ImportExamController(HttpTrigger httpTrigger, CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing,
|
|
|
+ IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, IConfiguration configuration, IWebHostEnvironment env)
|
|
|
+ {
|
|
|
+ _environment = env;
|
|
|
+ _coreAPIHttpService = coreAPIHttpService;
|
|
|
+ _azureCosmos = azureCosmos;
|
|
|
+ _serviceBus = serviceBus;
|
|
|
+ _snowflakeId = snowflakeId;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _option = option?.Value;
|
|
|
+ _azureStorage = azureStorage;
|
|
|
+ _azureRedis = azureRedis;
|
|
|
+ _configuration = configuration;
|
|
|
+ _httpTrigger = httpTrigger;
|
|
|
+ }
|
|
|
+
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "teacher,admin")]
|
|
|
+ [HttpPost("import-check")]
|
|
|
+
|
|
|
+
|
|
|
+#if !DEBUG
|
|
|
+ [Authorize(Roles = "IES")]
|
|
|
+#endif
|
|
|
+ public async Task<IActionResult> ImportCheck(JsonElement json) {
|
|
|
+
|
|
|
+ var importExam = json.ToObject<ImportExam>();
|
|
|
+
|
|
|
+ var validData= importExam.Valid();
|
|
|
+
|
|
|
+
|
|
|
+ string sql = $"select value c from c where c.name ='{importExam.name}'";
|
|
|
+ var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<ExamImport>(sql,$"ExamImport-{importExam.school}",pageSize:1);
|
|
|
+ ExamImport examImport = null;
|
|
|
+ if (string.IsNullOrEmpty(result.continuationToken)) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if (result.list.IsNotEmpty()) {
|
|
|
+ examImport = result.list[0];
|
|
|
+ }
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|