|
@@ -86,16 +86,26 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
|
|
string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
var json = JsonDocument.Parse(data).RootElement;
|
|
var json = JsonDocument.Parse(data).RootElement;
|
|
json.TryGetProperty("areaId", out JsonElement _areaId);
|
|
json.TryGetProperty("areaId", out JsonElement _areaId);
|
|
- string schoolSQL = $"select c.id ,c.name ,c.period from c where c.areaId='{_areaId}'";
|
|
|
|
|
|
+ string schoolSQL = $"select value c from c where c.areaId='{_areaId}'";
|
|
List<School> schools = new List<School>();
|
|
List<School> schools = new List<School>();
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
|
|
.GetItemQueryIterator<School>(queryText: schoolSQL, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
|
|
.GetItemQueryIterator<School>(queryText: schoolSQL, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
|
|
{
|
|
{
|
|
schools.Add(item);
|
|
schools.Add(item);
|
|
}
|
|
}
|
|
- ArtSetting artSetting= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<ArtSetting>($"{_areaId}", new PartitionKey());
|
|
|
|
|
|
+ ArtSetting artSetting= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<ArtSetting>($"{_areaId}", new PartitionKey("ArtSetting"));
|
|
foreach (var school in schools) {
|
|
foreach (var school in schools) {
|
|
- var periods = school.period.Where(p => p.type.IsNotEmpty());
|
|
|
|
|
|
+ List<Period> periods = new List<Period>();
|
|
|
|
+ var hastype = school.period.Where(p => p.type.IsNotEmpty());
|
|
|
|
+ if (hastype.Any()) {
|
|
|
|
+ periods.AddRange(hastype);
|
|
|
|
+ }
|
|
|
|
+ var nottype = school.period.Where(p => p.type.IsEmpty());
|
|
|
|
+ if (nottype.Any()) {
|
|
|
|
+ foreach (var type in nottype) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
foreach (var period in periods)
|
|
foreach (var period in periods)
|
|
{
|
|
{
|
|
var dimension = artSetting.dimensions.FindAll(x => x.type.Intersect(period.type).Any());
|
|
var dimension = artSetting.dimensions.FindAll(x => x.type.Intersect(period.type).Any());
|
|
@@ -193,6 +203,7 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(school , school.id, new PartitionKey(school.code));
|
|
}
|
|
}
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|