|
@@ -0,0 +1,65 @@
|
|
|
+using Azure.Cosmos;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.Filter;
|
|
|
+using TEAMModelOS.Models;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
+using TEAMModelOS.SDK.Models;
|
|
|
+
|
|
|
+namespace TEAMModelOS.Controllers
|
|
|
+{
|
|
|
+ [ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
+ //[Authorize(Roles = "IES5")]
|
|
|
+ [Route("research/ability")]
|
|
|
+ [ApiController]
|
|
|
+ public class StandardFileController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly AzureCosmosFactory _azureCosmos;
|
|
|
+ private readonly SnowflakeId _snowflakeId;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly Option _option;
|
|
|
+ public StandardFileController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
+ {
|
|
|
+ _azureCosmos = azureCosmos;
|
|
|
+ _snowflakeId = snowflakeId;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _option = option?.Value; ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ {"abilityId":"册别id:0baf00db-0768-4b62-a8f7-280f6bcebf71","scope":"school","abilityCode":"册别分区键"}
|
|
|
+ */
|
|
|
+ /// <summary>
|
|
|
+ /// 查找能力点
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("find-id")]
|
|
|
+ [AuthToken(Roles = "teacher,student,admin,area")]
|
|
|
+ public async Task<IActionResult> FindId(JsonElement request)
|
|
|
+ {
|
|
|
+
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ if (!request.TryGetProperty("areaId", out JsonElement _areaId)) return BadRequest();
|
|
|
+ StandardFile file = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<StandardFile>($"{_areaId}",partitionKey:new Azure.Cosmos.PartitionKey ("StandardFile"));
|
|
|
+ return Ok(new {});
|
|
|
+ }
|
|
|
+ catch (CosmosException ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ return Ok(new { file });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|