|
@@ -275,5 +275,63 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
|
return Ok(new { state = RespondCode.Ok, bizConfig });
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 查询所有学校 如果传企业ID则查询与企业没有关联的学校
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-schools")]
|
|
|
+ public async Task<IActionResult> GetSchools(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ jsonElement.TryGetProperty("id", out JsonElement id);
|
|
|
+ jsonElement.TryGetProperty("site", out JsonElement site);
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
+ if ($"{site}".Equals(BIConst.Global))
|
|
|
+ {
|
|
|
+ cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
+ tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
|
|
|
+ blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<OpenSchool> openSchools = new();
|
|
|
+
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<OpenSchool>(queryText: "select c.id,c.code,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
+ openSchools.Add(item);
|
|
|
+ }
|
|
|
+ BizConfig bizConfig = new();
|
|
|
+ if (!string.IsNullOrEmpty($"id"))
|
|
|
+ {
|
|
|
+ var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
|
|
|
+ if (response.Status == RespondCode.Ok)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ bizConfig = json.ToObject<BizConfig>();
|
|
|
+ if (bizConfig.schools.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in bizConfig.schools)
|
|
|
+ {
|
|
|
+ var temp = openSchools.Find(f => f.id.Equals(item.id));
|
|
|
+ if (temp != null)
|
|
|
+ openSchools.Remove(temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok , openSchools });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public record OpenSchool
|
|
|
+ {
|
|
|
+ public string id { get; set; }
|
|
|
+ public string code { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+ public string picture { get; set; }
|
|
|
+ }
|
|
|
}
|
|
|
}
|