|
@@ -313,7 +313,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
-
|
|
|
+ requert.TryGetProperty("period", out JsonElement _period) ;
|
|
|
try
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
@@ -340,8 +340,12 @@ namespace TEAMModelOS.Controllers
|
|
|
var query = $"select c.code,c.id,c.no,c.name,c.period,c.subject,c.scope from c";
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
+ string sql = query;
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{_period}")) {
|
|
|
+ sql = $"{sql} where c.period.id ='{_period}'";
|
|
|
+ }
|
|
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
{
|
|
|
//continuationToken = item.GetContinuationToken();
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -374,6 +378,11 @@ namespace TEAMModelOS.Controllers
|
|
|
if (requert.TryGetProperty("schoolId", out JsonElement schoolId))
|
|
|
{
|
|
|
var querySchool = $"select distinct c.code,c.id,c.no,c.name,c.period,c.subject,c.scope from c join A0 in c.schedule where A0.teacherId = '{code}'";
|
|
|
+
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{_period}"))
|
|
|
+ {
|
|
|
+ querySchool = $"{querySchool} and c.period.id ='{_period}'";
|
|
|
+ }
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
{
|
|
|
//continuationToken = item.GetContinuationToken();
|