|
@@ -172,6 +172,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(school.schoolId) )
|
|
|
{
|
|
|
+
|
|
|
if (school.status.Equals("join")) {
|
|
|
List<GroupList> yxtrain = groupLists.FindAll(x=>x.code.Equals($"GroupList-{school.schoolId}"));
|
|
|
if (yxtrain.IsNotEmpty())
|
|
@@ -222,6 +223,23 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
};
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(teacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
}
|
|
|
+ else {
|
|
|
+ JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ SchoolTeacher schoolTeacher = document.RootElement.ToObject<SchoolTeacher>();
|
|
|
+ schoolTeacher.status =school.status;
|
|
|
+ schoolTeacher.pk = "Teacher";
|
|
|
+ schoolTeacher.name = teacher.name;
|
|
|
+ schoolTeacher.picture = teacher.picture;
|
|
|
+ if (schoolTeacher.roles.IsEmpty() || !schoolTeacher.roles.Contains("teacher"))
|
|
|
+ {
|
|
|
+ schoolTeacher.roles = new List<string> { "teacher" };
|
|
|
+ }
|
|
|
+ schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty() ? schoolTeacher.permissions : new List<string>();
|
|
|
+
|
|
|
+ schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ schoolTeacher.ttl = -1;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -313,6 +331,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
foreach (var school in teacher.schools)
|
|
|
{
|
|
|
+
|
|
|
if (!string.IsNullOrEmpty(school.schoolId))
|
|
|
{
|
|
|
if (school.status.Equals("join")) {
|
|
@@ -369,7 +388,23 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
ttl = -1
|
|
|
};
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(teacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(schoolTeacher, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ SchoolTeacher schoolTeacher = document.RootElement.ToObject<SchoolTeacher>();
|
|
|
+ schoolTeacher.status = school.status;
|
|
|
+ schoolTeacher.pk = "Teacher";
|
|
|
+ schoolTeacher.name = teacher.name;
|
|
|
+ schoolTeacher.picture = teacher.picture;
|
|
|
+ if (schoolTeacher.roles.IsEmpty() || !schoolTeacher.roles.Contains("teacher"))
|
|
|
+ {
|
|
|
+ schoolTeacher.roles = new List<string> { "teacher" };
|
|
|
+ }
|
|
|
+ schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty() ? schoolTeacher.permissions : new List<string>();
|
|
|
+ schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ schoolTeacher.ttl = -1;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -601,6 +636,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
bind.account = Account;
|
|
|
if (teacher.schools.IsNotEmpty()) {
|
|
|
foreach (var school in teacher.schools) {
|
|
|
+
|
|
|
if (!string.IsNullOrEmpty(school.schoolId) ) {
|
|
|
if (school.status.Equals("join")) {
|
|
|
StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
|
|
@@ -651,11 +687,27 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
size=0,
|
|
|
roles=new List<string> { "teacher" },
|
|
|
permissions= new List<string>(),
|
|
|
- status="join",
|
|
|
+ status=school.status,
|
|
|
createTime=DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
ttl=-1
|
|
|
};
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(teacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(schoolTeacher, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ SchoolTeacher schoolTeacher = document.RootElement.ToObject<SchoolTeacher>();
|
|
|
+ schoolTeacher.status =school.status;
|
|
|
+ schoolTeacher.pk = "Teacher";
|
|
|
+ schoolTeacher.name = teacher.name;
|
|
|
+ schoolTeacher.picture = teacher.picture;
|
|
|
+ if (schoolTeacher.roles.IsEmpty() ||! schoolTeacher.roles.Contains("teacher")) {
|
|
|
+ schoolTeacher.roles = new List<string> { "teacher" };
|
|
|
+ }
|
|
|
+ schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty()? schoolTeacher.permissions: new List<string>();
|
|
|
+ schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ schoolTeacher.ttl = -1;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
}
|
|
|
}
|
|
|
}
|