|
@@ -0,0 +1,76 @@
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.Models;
|
|
|
+using TEAMModelOS.SDK;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
+using System.Text.Json;
|
|
|
+using TEAMModelOS.SDK.Models;
|
|
|
+using TEAMModelOS.SDK.Extension;
|
|
|
+using Azure.Cosmos;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using System.IO;
|
|
|
+using System.Dynamic;
|
|
|
+using System.Net.Http;
|
|
|
+using System.Net;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using System.Linq;
|
|
|
+using StackExchange.Redis;
|
|
|
+using static TEAMModelOS.SDK.Models.Teacher;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
+using TEAMModelOS.Filter;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+
|
|
|
+namespace TEAMModelAPI.Controllers
|
|
|
+{
|
|
|
+ [ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
+ [ApiController]
|
|
|
+ [Route("school")]
|
|
|
+ public class SchoolController : ControllerBase
|
|
|
+ {
|
|
|
+ public AzureCosmosFactory _azureCosmos;
|
|
|
+ private readonly AzureStorageFactory _azureStorage;
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly Option _option;
|
|
|
+ int baseSpaceSize = 1; //學校保底空間大小(1G)
|
|
|
+ private readonly double bytes = 1073741824;
|
|
|
+ private readonly int redisAclassoneDbNum = 8; //AclassOne Redis DB號
|
|
|
+ private readonly IConfiguration _configuration;
|
|
|
+ public SchoolController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
|
|
|
+ {
|
|
|
+ _azureCosmos = azureCosmos;
|
|
|
+ _azureStorage = azureStorage;
|
|
|
+ _azureRedis = azureRedis;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _option = option?.Value;
|
|
|
+ _configuration = configuration;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 学校信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpGet("get-school-info")]
|
|
|
+ [ApiToken(Auth = "1",Name = "学校信息", Limit=true)]
|
|
|
+ public async Task<IActionResult> GetSchoolInfo()
|
|
|
+ {
|
|
|
+ var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
+ School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ List<dynamic> period = new List<dynamic>();
|
|
|
+ data.period.ForEach(x => { period.Add(new { x.subjects ,x.grades,x.name,x.id,x.campusId,x.semesters}); });
|
|
|
+ return Ok(new {
|
|
|
+ id = data.id, name = data.name, data.areaId, type = data.type,
|
|
|
+ data.region, data.province, data.city, data.dist,
|
|
|
+ campuses=data.campuses,
|
|
|
+ period
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|