|
@@ -221,7 +221,7 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
[AuthToken(Roles = "admin,rdc")]
|
|
[AuthToken(Roles = "admin,rdc")]
|
|
[HttpPost("set-manage")]
|
|
[HttpPost("set-manage")]
|
|
- public async Task<IActionResult> SetAreaManage(JsonElement jsonElement)
|
|
|
|
|
|
+ public async Task<IActionResult> SetAreaManage(JsonElement jsonElement)
|
|
{
|
|
{
|
|
var (_tmdId, _tmdName, _, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
var (_tmdId, _tmdName, _, _, _, _) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
|
|
|
@@ -279,67 +279,72 @@ namespace TEAMModelBI.Controllers.BINormal
|
|
strMsg.Append("设置为区管理员!");
|
|
strMsg.Append("设置为区管理员!");
|
|
}
|
|
}
|
|
|
|
|
|
- if ($"{isSc}".Equals("yesm"))
|
|
|
|
|
|
+ if (existsArea == null)
|
|
{
|
|
{
|
|
- List<SimpleInfo> schoolMs = scInfos.ToObject<List<SimpleInfo>>();
|
|
|
|
- if (schoolMs.Count > 0)
|
|
|
|
|
|
+ if ($"{isSc}".Equals("yesm"))
|
|
{
|
|
{
|
|
- strMsg.Append($"并将改账户设置为学校管理员;修改信息:");
|
|
|
|
- foreach (var item in schoolMs)
|
|
|
|
|
|
+ List<SimpleInfo> schoolMs = scInfos.ToObject<List<SimpleInfo>>();
|
|
|
|
+ if (schoolMs.Count > 0)
|
|
{
|
|
{
|
|
- var resSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{item.id}", new PartitionKey($"Base"));
|
|
|
|
- if (resSc.Status == 200)
|
|
|
|
|
|
+ strMsg.Append($"并将改账户设置为学校管理员;修改信息:");
|
|
|
|
+ foreach (var item in schoolMs)
|
|
{
|
|
{
|
|
- SchoolTeacher schoolTeacher = null;
|
|
|
|
- var resScTch = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{item.id}"));
|
|
|
|
- if (resScTch.Status == 200)
|
|
|
|
|
|
+ var resSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{item.id}", new PartitionKey($"Base"));
|
|
|
|
+ if (resSc.Status == 200)
|
|
{
|
|
{
|
|
- using var json = await JsonDocument.ParseAsync(resScTch.ContentStream);
|
|
|
|
- schoolTeacher = json.ToObject<SchoolTeacher>();
|
|
|
|
- if (!schoolTeacher.roles.Contains("admin"))
|
|
|
|
|
|
+ SchoolTeacher schoolTeacher = null;
|
|
|
|
+ var resScTch = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{item.id}"));
|
|
|
|
+ if (resScTch.Status == 200)
|
|
{
|
|
{
|
|
- schoolTeacher.roles.Add("admin");
|
|
|
|
- schoolTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{item.id}"));
|
|
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(resScTch.ContentStream);
|
|
|
|
+ schoolTeacher = json.ToObject<SchoolTeacher>();
|
|
|
|
+ if (!schoolTeacher.roles.Contains("admin"))
|
|
|
|
+ {
|
|
|
|
+ schoolTeacher.roles.Add("admin");
|
|
|
|
+ schoolTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{item.id}"));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ existsSc.Add(item);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- existsSc.Add(item);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- schoolTeacher = new()
|
|
|
|
{
|
|
{
|
|
- id = $"{tmdId}",
|
|
|
|
- code = $"Teacher-{item.id}",
|
|
|
|
- roles = new List<string> { "admin", "teacher" },
|
|
|
|
- job = "管理员",
|
|
|
|
- name = $"{tmdName}",
|
|
|
|
- picture = string.IsNullOrEmpty($"{item.picture}") ? "" : $"{item.picture}",
|
|
|
|
- status = "join",
|
|
|
|
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
|
- pk = "Teacher",
|
|
|
|
- ttl = -1
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey($"Teacher-{item.id}"));
|
|
|
|
- }
|
|
|
|
|
|
+ schoolTeacher = new()
|
|
|
|
+ {
|
|
|
|
+ id = $"{tmdId}",
|
|
|
|
+ code = $"Teacher-{item.id}",
|
|
|
|
+ roles = new List<string> { "admin", "teacher" },
|
|
|
|
+ job = "管理员",
|
|
|
|
+ name = $"{tmdName}",
|
|
|
|
+ picture = string.IsNullOrEmpty($"{item.picture}") ? "" : $"{item.picture}",
|
|
|
|
+ status = "join",
|
|
|
|
+ createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
|
+ pk = "Teacher",
|
|
|
|
+ ttl = -1
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey($"Teacher-{item.id}"));
|
|
|
|
+ }
|
|
|
|
|
|
- var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{item.id}"));
|
|
|
|
- if (existArea == null)
|
|
|
|
- {
|
|
|
|
- teacher.schools.Add(new Teacher.TeacherSchool { schoolId = $"{item.id}", name = $"{item.name}", status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = string.IsNullOrEmpty($"{item.picture}") ? "" : $"{item.picture}", areaId = $"{areaId}" });
|
|
|
|
- }
|
|
|
|
|
|
+ var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{item.id}"));
|
|
|
|
+ if (existArea == null)
|
|
|
|
+ {
|
|
|
|
+ teacher.schools.Add(new Teacher.TeacherSchool { schoolId = $"{item.id}", name = $"{item.name}", status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = string.IsNullOrEmpty($"{item.picture}") ? "" : $"{item.picture}", areaId = $"{areaId}" });
|
|
|
|
+ }
|
|
|
|
|
|
- strMsg.Append($"{item.name}【{item.id}】|");
|
|
|
|
|
|
+ strMsg.Append($"{item.name}【{item.id}】|");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorSc.Add(item);
|
|
}
|
|
}
|
|
- else
|
|
|
|
- errorSc.Add(item);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
|
|
|
|
+ teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ existsSc = schoolMs;
|
|
}
|
|
}
|
|
- else
|
|
|
|
- existsSc = schoolMs;
|
|
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ return Ok(new { state = RespondCode.Conflict, msg = "你已经是该区管理员!" });
|
|
|
|
|
|
//保存操作记录
|
|
//保存操作记录
|
|
await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "schoolTeacher-add", strMsg.ToString(), _dingDing, httpContext: HttpContext);
|
|
await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "schoolTeacher-add", strMsg.ToString(), _dingDing, httpContext: HttpContext);
|