|
@@ -301,6 +301,7 @@ namespace TEAMModelOS.Controllers
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
[HttpPost("get-school-product")]
|
|
[HttpPost("get-school-product")]
|
|
|
|
+ [AuthToken(Roles = "admin,teacher")]
|
|
[Authorize(Roles = "IES")]
|
|
[Authorize(Roles = "IES")]
|
|
public async Task<IActionResult> GetSchoolProductInfo(JsonElement request)
|
|
public async Task<IActionResult> GetSchoolProductInfo(JsonElement request)
|
|
{
|
|
{
|
|
@@ -435,179 +436,154 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
//服務
|
|
//服務
|
|
- long teacherSize = 0;
|
|
|
|
- bool buySpaceFlg = false;
|
|
|
|
- Dictionary<string, double> spaceinfo = new Dictionary<string, double>();
|
|
|
|
- spaceinfo["student"] = 0;
|
|
|
|
- spaceinfo["record"] = 0;
|
|
|
|
- spaceinfo["doc"] = 0;
|
|
|
|
- spaceinfo["video"] = 0;
|
|
|
|
- spaceinfo["image"] = 0;
|
|
|
|
- spaceinfo["res"] = 0;
|
|
|
|
- spaceinfo["video"] = 0;
|
|
|
|
- spaceinfo["audio"] = 0;
|
|
|
|
- spaceinfo["vote"] = 0;
|
|
|
|
- spaceinfo["survey"] = 0;
|
|
|
|
- spaceinfo["item"] = 0;
|
|
|
|
- spaceinfo["paper"] = 0;
|
|
|
|
- spaceinfo["syllabus"] = 0;
|
|
|
|
- spaceinfo["avatar"] = 0;
|
|
|
|
- spaceinfo["record"] = 0;
|
|
|
|
- spaceinfo["other"] = 0;
|
|
|
|
- spaceinfo["student"] = 0;
|
|
|
|
- spaceinfo["teacher"] = teacherSize;
|
|
|
|
- SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{school_code}");
|
|
|
|
- if (Scores != null)
|
|
|
|
|
|
+ List<SchoolProductSumDataService> service = new List<SchoolProductSumDataService>();
|
|
|
|
+ await foreach (var items in clientContainer.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
|
|
{
|
|
{
|
|
- foreach (var score in Scores)
|
|
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(items.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
- double val = score.Score;
|
|
|
|
- string key = score.Element.ToString();
|
|
|
|
- spaceinfo[key] = val;
|
|
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ SchoolProductSum schoolProductSum = obj.ToObject<SchoolProductSum>();
|
|
|
|
+ service = schoolProductSum.service;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- ////取得教師分配空間
|
|
|
|
- var querysp = $"SELECT SUM(c.size) as size FROM c";
|
|
|
|
- await foreach (var item in clientContainer.GetItemQueryStreamIterator(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
|
|
|
|
|
|
+ if(service.Count > 0)
|
|
{
|
|
{
|
|
- var jsonts = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
- foreach (var obj in jsonts.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
|
|
+ foreach(SchoolProductSumDataService serviceRow in service)
|
|
{
|
|
{
|
|
- teacherSize = obj.GetProperty("size").GetInt64() * 1073741824;//G換算成bytes
|
|
|
|
|
|
+ SchoolProductOrder spOrderRow = new SchoolProductOrder();
|
|
|
|
+ spOrderRow.prodCode = serviceRow.prodCode;
|
|
|
|
+ spOrderRow.avaliable = serviceRow.avaliable;
|
|
|
|
+ spOrderRow.avaliableStartDate = serviceRow.startDate;
|
|
|
|
+ spOrderRow.avaliableEndDate = serviceRow.endDate;
|
|
|
|
+ serviceOrder.Add(spOrderRow);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- SchoolProductSumData spaceDum = serviceSum.Where(svsum => svsum.prodCode.Equals("IPALJ6NY")).FirstOrDefault(); //取得目前學校空間可用數
|
|
|
|
- spaceinfo["avaliable"] = (spaceDum != null) ? Convert.ToInt64(spaceDum.avaliable) * 1073741824 : 0; //G換算成bytes
|
|
|
|
- spaceinfo["startDate"] = 0;
|
|
|
|
- spaceinfo["endDate"] = 0;
|
|
|
|
-
|
|
|
|
- ////取得學校空間使用狀況
|
|
|
|
- //var blobClient = _azureStorage.GetBlobContainerClient(school_code.ToString());
|
|
|
|
- //long? docSize = await blobClient.GetBlobsSize("doc");
|
|
|
|
- //long? imageSize = await blobClient.GetBlobsSize("image");
|
|
|
|
- //long? resSize = await blobClient.GetBlobsSize("res");
|
|
|
|
- //long? videoSize = await blobClient.GetBlobsSize("video");
|
|
|
|
- //long? audioSize = await blobClient.GetBlobsSize("audio");
|
|
|
|
- //long? examSize = await blobClient.GetBlobsSize("exam");
|
|
|
|
- //long? voteSize = await blobClient.GetBlobsSize("vote");
|
|
|
|
- //long? surveySize = await blobClient.GetBlobsSize("survey");
|
|
|
|
- //long? itemSize = await blobClient.GetBlobsSize("item");
|
|
|
|
- //long? paperSize = await blobClient.GetBlobsSize("paper");
|
|
|
|
- //long? syllabusSize = await blobClient.GetBlobsSize("syllabus");
|
|
|
|
- //long? avatarSize = await blobClient.GetBlobsSize("avatar");
|
|
|
|
- //long? recordSize = await blobClient.GetBlobsSize("records");
|
|
|
|
- //long? otherSize = await blobClient.GetBlobsSize("other");
|
|
|
|
- //long? studentSize = await blobClient.GetBlobsSize("student");
|
|
|
|
- //dynamic spaceinfo = new ExpandoObject();
|
|
|
|
- //spaceinfo.doc = docSize;
|
|
|
|
- //spaceinfo.video = videoSize;
|
|
|
|
- //spaceinfo.image = imageSize;
|
|
|
|
- //spaceinfo.res = resSize;
|
|
|
|
- //spaceinfo.video = voteSize;
|
|
|
|
- //spaceinfo.audio = audioSize;
|
|
|
|
- //spaceinfo.vote = voteSize;
|
|
|
|
- //spaceinfo.survey = surveySize;
|
|
|
|
- //spaceinfo.item = itemSize;
|
|
|
|
- //spaceinfo.paper = paperSize;
|
|
|
|
- //spaceinfo.syllabus = syllabusSize;
|
|
|
|
- //spaceinfo.avatar = avatarSize;
|
|
|
|
- //spaceinfo.record = recordSize;
|
|
|
|
- //spaceinfo.other = otherSize;
|
|
|
|
- //spaceinfo.student = studentSize;
|
|
|
|
- //spaceinfo.teacher = teacherSize;
|
|
|
|
- //SchoolProductSumData spaceDum = serviceSum.Where(svsum => svsum.prodCode.Equals("IPALJ6NY")).FirstOrDefault(); //取得目前學校空間可用數
|
|
|
|
- //spaceinfo.avaliable = (spaceDum != null) ? Convert.ToInt64(spaceDum.avaliable) * 1073741824 : 0; //G換算成bytes
|
|
|
|
- //spaceinfo.startDate = 0;
|
|
|
|
- //spaceinfo.endDate = 0;
|
|
|
|
|
|
+
|
|
|
|
+ #region 產品購買履歷廢除部分
|
|
////(服務)取得各產品購買履歷
|
|
////(服務)取得各產品購買履歷
|
|
- await foreach (var itemsv in clientContainer.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'service'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
|
|
|
+ //await foreach (var itemsv in clientContainer.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'service'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
|
+ //{
|
|
|
|
+ // using var json = await JsonDocument.ParseAsync(itemsv.ContentStream);
|
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ // {
|
|
|
|
+ // foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ // {
|
|
|
|
+ // SchoolProductService serviceProductRow = obj.ToObject<SchoolProductService>();
|
|
|
|
+ // serviceProduct.Add(serviceProductRow);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ ////(服務)產品購買履歷整形
|
|
|
|
+ //IEnumerable<SchoolProductService> serviceProductOrder = serviceProduct.OrderBy(sp => sp.startDate);
|
|
|
|
+ //foreach (SchoolProductService serviceProductRow in serviceProduct)
|
|
|
|
+ //{
|
|
|
|
+ // //取得此產品現在可用數
|
|
|
|
+ // SchoolProductSumDataService serviceSumNow = serviceSum.Where(ss => ss.prodCode.Equals(serviceProductRow.prodCode)).FirstOrDefault();
|
|
|
|
+ // int serviceAvaliableNow = (serviceSumNow != null) ? serviceSumNow.avaliable : 0;
|
|
|
|
+ // long serviceAvaliableStartDate = (serviceSumNow != null) ? serviceSumNow.startDate : 0;
|
|
|
|
+ // long serviceAvaliableEndDate = (serviceSumNow != null) ? serviceSumNow.endDate : 0;
|
|
|
|
+ // //取得此產品購買履歷
|
|
|
|
+ // SchoolProductOrder serviceOrderNow = serviceOrder.Where(so => so.prodCode == serviceProductRow.prodCode).FirstOrDefault();
|
|
|
|
+ // if (serviceOrderNow == null) //無此產品項
|
|
|
|
+ // {
|
|
|
|
+ // SchoolProductOrder serviceOrderRow = new SchoolProductOrder();
|
|
|
|
+ // serviceOrderRow.prodCode = serviceProductRow.prodCode;
|
|
|
|
+ // serviceOrderRow.order = new List<SchoolProductOrderList>();
|
|
|
|
+ // SchoolProductOrderList serviceOrderRowOrderList = new SchoolProductOrderList();
|
|
|
|
+ // serviceOrderRowOrderList.id = serviceProductRow.id;
|
|
|
|
+ // serviceOrderRowOrderList.orderDate = serviceProductRow.orderDate;
|
|
|
|
+ // serviceOrderRowOrderList.startDate = serviceProductRow.startDate;
|
|
|
|
+ // serviceOrderRowOrderList.endDate = serviceProductRow.endDate;
|
|
|
|
+ // serviceOrderRowOrderList.number = serviceProductRow.number;
|
|
|
|
+ // serviceOrderRowOrderList.unit = serviceProductRow.unit;
|
|
|
|
+ // serviceOrderRow.order.Add(serviceOrderRowOrderList);
|
|
|
|
+ // serviceOrderRow.avaliable = serviceAvaliableNow;
|
|
|
|
+ // serviceOrderRow.avaliableStartDate = serviceAvaliableStartDate;
|
|
|
|
+ // serviceOrderRow.avaliableEndDate = serviceAvaliableEndDate;
|
|
|
|
+ // serviceOrder.Add(serviceOrderRow);
|
|
|
|
+ // }
|
|
|
|
+ // else //有此產品項 => 看是否有此購買紀錄
|
|
|
|
+ // {
|
|
|
|
+ // //記入可用起始終止日
|
|
|
|
+ // serviceOrderNow.avaliableStartDate = serviceAvaliableStartDate;
|
|
|
|
+ // serviceOrderNow.avaliableEndDate = serviceAvaliableEndDate;
|
|
|
|
+ // //記入購買紀錄
|
|
|
|
+ // SchoolProductOrderList SchoolProductOrderListNow = serviceOrderNow.order.Where(Sol => Sol.id.Equals(serviceProductRow.id)).FirstOrDefault();
|
|
|
|
+ // if (SchoolProductOrderListNow == null) //無此購買紀錄
|
|
|
|
+ // {
|
|
|
|
+ // SchoolProductOrderList serviceOrderRowOrderList = new SchoolProductOrderList();
|
|
|
|
+ // serviceOrderRowOrderList.id = serviceProductRow.id;
|
|
|
|
+ // serviceOrderRowOrderList.orderDate = serviceProductRow.orderDate;
|
|
|
|
+ // serviceOrderRowOrderList.startDate = serviceProductRow.startDate;
|
|
|
|
+ // serviceOrderRowOrderList.endDate = serviceProductRow.endDate;
|
|
|
|
+ // serviceOrderRowOrderList.number = serviceProductRow.number;
|
|
|
|
+ // serviceOrderRowOrderList.unit = serviceProductRow.unit;
|
|
|
|
+ // serviceOrderNow.order.Add(serviceOrderRowOrderList);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ //硬體
|
|
|
|
+ await foreach (var itemhd in clientContainer.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
{
|
|
{
|
|
- using var json = await JsonDocument.ParseAsync(itemsv.ContentStream);
|
|
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(itemhd.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
{
|
|
{
|
|
- SchoolProductService serviceProductRow = obj.ToObject<SchoolProductService>();
|
|
|
|
- serviceProduct.Add(serviceProductRow);
|
|
|
|
- //學校空間特別處理:取得起始結束時間
|
|
|
|
- if (serviceProductRow.code.Equals("IPALJ6NY"))
|
|
|
|
- {
|
|
|
|
- if (serviceProductRow.startDate < UTCNow && UTCNow < serviceProductRow.endDate)
|
|
|
|
- {
|
|
|
|
- spaceinfo["startDate"] = serviceProductRow.startDate;
|
|
|
|
- spaceinfo["endDate"] = serviceProductRow.endDate;
|
|
|
|
- // spaceinfo.startDate = serviceProductRow.startDate;
|
|
|
|
- //spaceinfo.endDate = serviceProductRow.endDate;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ hard.Add(obj.ToObject<SchoolProductHard>());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ////(服務)產品購買履歷整形
|
|
|
|
- IEnumerable<SchoolProductService> serviceProductOrder = serviceProduct.OrderBy(sp => sp.startDate);
|
|
|
|
- foreach (SchoolProductService serviceProductRow in serviceProduct)
|
|
|
|
|
|
+
|
|
|
|
+ //空間計算
|
|
|
|
+ ////取得教師分配空間
|
|
|
|
+ long teach = 0;
|
|
|
|
+ var querysp = $"SELECT SUM(c.size) as size FROM c";
|
|
|
|
+ await foreach (var item in clientContainer.GetItemQueryStreamIterator(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
|
|
{
|
|
{
|
|
- //取得此產品現在可用數
|
|
|
|
- SchoolProductSumDataService serviceSumNow = serviceSum.Where(ss => ss.prodCode.Equals(serviceProductRow.prodCode)).FirstOrDefault();
|
|
|
|
- int serviceAvaliableNow = (serviceSumNow != null) ? serviceSumNow.avaliable : 0;
|
|
|
|
- long serviceAvaliableStartDate = (serviceSumNow != null) ? serviceSumNow.startDate : 0;
|
|
|
|
- long serviceAvaliableEndDate = (serviceSumNow != null) ? serviceSumNow.endDate : 0;
|
|
|
|
- //取得此產品購買履歷
|
|
|
|
- SchoolProductOrder serviceOrderNow = serviceOrder.Where(so => so.prodCode == serviceProductRow.prodCode).FirstOrDefault();
|
|
|
|
- if (serviceOrderNow == null) //無此產品項
|
|
|
|
|
|
+ var jsonts = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ foreach (var obj in jsonts.RootElement.GetProperty("Documents").EnumerateArray())
|
|
{
|
|
{
|
|
- SchoolProductOrder serviceOrderRow = new SchoolProductOrder();
|
|
|
|
- serviceOrderRow.prodCode = serviceProductRow.prodCode;
|
|
|
|
- serviceOrderRow.order = new List<SchoolProductOrderList>();
|
|
|
|
- SchoolProductOrderList serviceOrderRowOrderList = new SchoolProductOrderList();
|
|
|
|
- serviceOrderRowOrderList.id = serviceProductRow.id;
|
|
|
|
- serviceOrderRowOrderList.orderDate = serviceProductRow.orderDate;
|
|
|
|
- serviceOrderRowOrderList.startDate = serviceProductRow.startDate;
|
|
|
|
- serviceOrderRowOrderList.endDate = serviceProductRow.endDate;
|
|
|
|
- serviceOrderRowOrderList.number = serviceProductRow.number;
|
|
|
|
- serviceOrderRowOrderList.unit = serviceProductRow.unit;
|
|
|
|
- serviceOrderRow.order.Add(serviceOrderRowOrderList);
|
|
|
|
- serviceOrderRow.avaliable = serviceAvaliableNow;
|
|
|
|
- serviceOrderRow.avaliableStartDate = serviceAvaliableStartDate;
|
|
|
|
- serviceOrderRow.avaliableEndDate = serviceAvaliableEndDate;
|
|
|
|
- serviceOrder.Add(serviceOrderRow);
|
|
|
|
|
|
+ teach = obj.GetProperty("size").GetInt64() * 1073741824; //G換算
|
|
}
|
|
}
|
|
- else //有此產品項 => 看是否有此購買紀錄
|
|
|
|
|
|
+ }
|
|
|
|
+ ////學校已使用空間
|
|
|
|
+ long blobsize = 0;
|
|
|
|
+ RedisValue value = default;
|
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", $"{school_code}");
|
|
|
|
+ if (value != default && !value.IsNullOrEmpty)
|
|
|
|
+ {
|
|
|
|
+ JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
|
|
+ if (record.TryGetInt64(out blobsize))
|
|
{
|
|
{
|
|
- //記入可用起始終止日
|
|
|
|
- serviceOrderNow.avaliableStartDate = serviceAvaliableStartDate;
|
|
|
|
- serviceOrderNow.avaliableEndDate = serviceAvaliableEndDate;
|
|
|
|
- //記入購買紀錄
|
|
|
|
- SchoolProductOrderList SchoolProductOrderListNow = serviceOrderNow.order.Where(Sol => Sol.id.Equals(serviceProductRow.id)).FirstOrDefault();
|
|
|
|
- if (SchoolProductOrderListNow == null) //無此購買紀錄
|
|
|
|
- {
|
|
|
|
- SchoolProductOrderList serviceOrderRowOrderList = new SchoolProductOrderList();
|
|
|
|
- serviceOrderRowOrderList.id = serviceProductRow.id;
|
|
|
|
- serviceOrderRowOrderList.orderDate = serviceProductRow.orderDate;
|
|
|
|
- serviceOrderRowOrderList.startDate = serviceProductRow.startDate;
|
|
|
|
- serviceOrderRowOrderList.endDate = serviceProductRow.endDate;
|
|
|
|
- serviceOrderRowOrderList.number = serviceProductRow.number;
|
|
|
|
- serviceOrderRowOrderList.unit = serviceProductRow.unit;
|
|
|
|
- serviceOrderNow.order.Add(serviceOrderRowOrderList);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //硬體
|
|
|
|
- await foreach (var itemhd in clientContainer.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
|
|
|
+ ////各項空間數值取得
|
|
|
|
+ Dictionary<string, double> catalog = new Dictionary<string, double>();
|
|
|
|
+ SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{school_code}");
|
|
|
|
+ if (Scores != null)
|
|
{
|
|
{
|
|
- using var json = await JsonDocument.ParseAsync(itemhd.ContentStream);
|
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
|
|
+ foreach (var score in Scores)
|
|
{
|
|
{
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
- {
|
|
|
|
- hard.Add(obj.ToObject<SchoolProductHard>());
|
|
|
|
- }
|
|
|
|
|
|
+ double val = score.Score;
|
|
|
|
+ string key = score.Element.ToString();
|
|
|
|
+ catalog.Add(key, val);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ dynamic space = new ExpandoObject();
|
|
|
|
+ space.size = blobsize;
|
|
|
|
+ space.teach = teach;
|
|
|
|
+ space.catalog = catalog;
|
|
|
|
|
|
- return Ok(new { serial = serialResult, service = serviceOrder, hard, spaceinfo });
|
|
|
|
|
|
+ //購買紀錄 ※DB資料未生成,先訂class 後補上
|
|
|
|
+ List<SchoolOrder> order = new List<SchoolOrder>();
|
|
|
|
+
|
|
|
|
+ return Ok(new { serial = serialResult, service = serviceOrder, hard, space, order });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -747,16 +723,15 @@ namespace TEAMModelOS.Controllers
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
[HttpPost("unbind-serial")]
|
|
[HttpPost("unbind-serial")]
|
|
[Authorize(Roles = "IES")]
|
|
[Authorize(Roles = "IES")]
|
|
|
|
+ [AuthToken(Roles = "admin,teacher")]
|
|
public async Task<IActionResult> UnbindSerial(JsonElement request)
|
|
public async Task<IActionResult> UnbindSerial(JsonElement request)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
//輸入參數
|
|
//輸入參數
|
|
- if (!request.TryGetProperty("id_token", out JsonElement id_token)) return BadRequest();
|
|
|
|
- var jwt = new JwtSecurityToken(id_token.GetString());
|
|
|
|
- var id = jwt.Payload.Sub;
|
|
|
|
- jwt.Payload.TryGetValue("name", out object name);
|
|
|
|
if (!request.TryGetProperty("serial", out JsonElement serialJson)) return BadRequest();
|
|
if (!request.TryGetProperty("serial", out JsonElement serialJson)) return BadRequest();
|
|
|
|
+ var (id, name, _, _) = HttpContext.GetAuthTokenInfo(); //取得IDToken資訊
|
|
|
|
+
|
|
request.TryGetProperty("uuid", out JsonElement uuidJson);
|
|
request.TryGetProperty("uuid", out JsonElement uuidJson);
|
|
request.TryGetProperty("uuid2", out JsonElement uuid2Json);
|
|
request.TryGetProperty("uuid2", out JsonElement uuid2Json);
|
|
string serial = serialJson.ToString();
|
|
string serial = serialJson.ToString();
|