CrazyIter_Bin 2 years ago
parent
commit
ba6891d31d
1 changed files with 14 additions and 3 deletions
  1. 14 3
      TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

+ 14 - 3
TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

@@ -86,16 +86,26 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
             string data = await new StreamReader(req.Body).ReadToEndAsync();
             var json = JsonDocument.Parse(data).RootElement;
             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>();
             await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
                            .GetItemQueryIterator<School>(queryText: schoolSQL, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
             {
                 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) {
-                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)
                 {
                     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;
         }