|
@@ -108,10 +108,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//Debug
|
|
|
//string teacher = Encoding.UTF8.GetString(stream.ToArray());
|
|
|
response = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOSTemp", "Teacher").CreateItemStreamAsync(stream, new PartitionKey("Base"));
|
|
|
- }
|
|
|
-
|
|
|
- //授權權杖
|
|
|
- string auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, _option.JwtSecretKey, "", new string[] { "Teacher" }, new string[] { });
|
|
|
+ }
|
|
|
|
|
|
//私人課程
|
|
|
List<object> courses = new List<object>();
|
|
@@ -141,6 +138,8 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, _option.JwtSecretKey, roles: new[] { "Teacher" });
|
|
|
+
|
|
|
//取得Teacher Blob 容器位置及SAS
|
|
|
var container = _azureStorage.GetBlobContainerClient(id);
|
|
|
await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
|
|
@@ -156,11 +155,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
[ProducesDefaultResponseType]
|
|
|
//[AuthToken(Roles = "Teacher")]
|
|
|
- [HttpPost("get-school-info")]
|
|
|
-
|
|
|
+ [HttpPost("get-school-info")]
|
|
|
public async Task<IActionResult> GetSchoolInfo(JsonElement requert)
|
|
|
{
|
|
|
//var (id, school) = HttpContext.GetAuthTokenInfo(); //此API有設置權杖,需要取得權杖使用者id及當前學校代碼(學校不一定有)
|
|
@@ -188,16 +185,15 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { courses });
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
//[AuthToken(Roles = "Teacher")]
|
|
|
- [HttpPost("get-school-list")]
|
|
|
-
|
|
|
+ [HttpPost("get-school-list")]
|
|
|
public async Task<IActionResult> GetSchoolList()
|
|
|
{
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
List<object> schools = new List<object>();
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOSTemp", "School").GetItemQueryStreamIterator(queryText: $"select c.id, c.name from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOSTemp", "School").GetItemQueryStreamIterator(queryText: $"select c.id, c.name,c.region,c.province,c.city from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|