|
@@ -786,12 +786,16 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
string stulist = Convert.ToString(stulist_id);
|
|
|
if(string.IsNullOrWhiteSpace(classId) && string.IsNullOrWhiteSpace(stulist)) return BadRequest();
|
|
|
request.TryGetProperty("school_code", out JsonElement school_code);
|
|
|
- if (grant_type.GetString() == "school" && string.IsNullOrEmpty(Convert.ToString(school_code))) return BadRequest();
|
|
|
+ if (grant_type.GetString() == "school" && string.IsNullOrWhiteSpace(Convert.ToString(school_code))) return BadRequest();
|
|
|
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
List<object> students = new List<object>();
|
|
|
string container = (grant_type.GetString() == "school") ? "School" : "Teacher";
|
|
|
//Case 1 取得stulist成員 (有stulist_id則優先取)
|
|
|
+ if (grant_type.GetString() == "private" && string.IsNullOrWhiteSpace(stulist) && !string.IsNullOrWhiteSpace(classId)) //若private,且classId不為空,stulist為空,有可能HiTeach無法判別是若classId還是stulist
|
|
|
+ {
|
|
|
+ stulist = classId;
|
|
|
+ }
|
|
|
if (!string.IsNullOrWhiteSpace(stulist))
|
|
|
{
|
|
|
string pk = (grant_type.GetString() == "school") ? $"StuList-{school_code}" : $"StuList";
|
|
@@ -847,8 +851,8 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //Case 2 取得班級固定成員
|
|
|
- if(grant_type.GetString() == "school" && students.Count == 0 && !string.IsNullOrWhiteSpace(classId) && string.IsNullOrWhiteSpace(stulist))
|
|
|
+ //Case 2 取得班級固定成員 條件:有school_code、有classId、無stulist
|
|
|
+ if (!string.IsNullOrWhiteSpace(Convert.ToString(school_code)) && students.Count == 0 && !string.IsNullOrWhiteSpace(classId))
|
|
|
{
|
|
|
var query = $"SELECT c.id, c.name, c.no, c.schoolId, c.groupId, c.groupName FROM c WHERE c.classId = '{classId}'";
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school_code}") }))
|
|
@@ -863,6 +867,7 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //Case 3 不論學校、個人 有classId,
|
|
|
|
|
|
return Ok(new { students });
|
|
|
}
|