|
@@ -841,6 +841,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
var (_tmdId, _tmdName, _, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("scIds", out JsonElement _scIds)) return BadRequest();
|
|
|
+ bool rmvFromSc = (!jsonElement.TryGetProperty("rmvFromSc", out JsonElement rmvFromScJobj)) ? rmvFromScJobj.GetBoolean() : false; //rmvFromSc Bool true:移除SchoolTeacher document false:只移除roles中"admin"身分
|
|
|
//jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
|
|
|
|
|
|
List<string> scIds = _scIds.ToObject<List<string>>();
|
|
@@ -858,16 +859,23 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
- scTeacher = json.ToObject<SchoolTeacher>();
|
|
|
- if (scTeacher.roles.Contains("admin"))
|
|
|
+ if (rmvFromSc)
|
|
|
{
|
|
|
- scTeacher.roles.Remove("admin");
|
|
|
- strMsg.Append($"{scId},");
|
|
|
- scTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(scTeacher, scTeacher.id, new PartitionKey($"Teacher-{scId}"));
|
|
|
+ await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
|
}
|
|
|
else
|
|
|
- existScId.Add(scId);
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ scTeacher = json.ToObject<SchoolTeacher>();
|
|
|
+ if (scTeacher.roles.Contains("admin"))
|
|
|
+ {
|
|
|
+ scTeacher.roles.Remove("admin");
|
|
|
+ strMsg.Append($"{scId},");
|
|
|
+ scTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(scTeacher, scTeacher.id, new PartitionKey($"Teacher-{scId}"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ existScId.Add(scId);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
existScId.Add(scId);
|