Parcourir la source

区域字段检查逻辑

CrazyIter_Bin il y a 3 ans
Parent
commit
c5b8696dd3

+ 0 - 2
TEAMModelOS.SDK/Models/Cosmos/School/ExamInfo.cs

@@ -117,8 +117,6 @@ namespace TEAMModelOS.SDK.Models
         public string id { get; set; }
         public string id { get; set; }
         public string name { get; set; }
         public string name { get; set; }
         public int classCount { get; set; }
         public int classCount { get; set; }
-       
-
     }
     }
     public class PaperSimple { 
     public class PaperSimple { 
         public string id { get; set; }
         public string id { get; set; }

+ 9 - 2
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -136,8 +136,8 @@ namespace TEAMModelOS.Controllers
                                 schoolExtobj.status =sc.status;
                                 schoolExtobj.status =sc.status;
                                 schoolExtobj.time = sc.time;
                                 schoolExtobj.time = sc.time;
                                 schoolExtobj.picture = school.RootElement.GetProperty("picture");
                                 schoolExtobj.picture = school.RootElement.GetProperty("picture");
-                                var areaId = school.RootElement.GetProperty("areaId");
-                                schoolExtobj.areaId = areaId;
+                                school.RootElement.TryGetProperty("areaId",out  JsonElement areaId);
+                                schoolExtobj.areaId = $"{areaId}";
                                 Area area = null;
                                 Area area = null;
                                 if (!string.IsNullOrEmpty($"{areaId}"))
                                 if (!string.IsNullOrEmpty($"{areaId}"))
                                 {
                                 {
@@ -187,6 +187,12 @@ namespace TEAMModelOS.Controllers
                             teacher.size = 1;
                             teacher.size = 1;
                         }
                         }
                     }
                     }
+                    if (string.IsNullOrEmpty(teacher.defaultSchool) && teacher.schools.IsNotEmpty()) {
+                        var tech = teacher.schools.FindAll(x => x.status.Equals("join"));
+                        if (tech.IsNotEmpty()) {
+                            teacher.defaultSchool = teacher.schools[0].schoolId;
+                        }
+                    }
                     await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
                     await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
                     //預設學校ID
                     //預設學校ID
                     defaultschool = teacher.defaultSchool;
                     defaultschool = teacher.defaultSchool;
@@ -256,6 +262,7 @@ namespace TEAMModelOS.Controllers
                 //取得Teacher Blob 容器位置及SAS 
                 //取得Teacher Blob 容器位置及SAS 
                 await _azureStorage.GetBlobContainerClient(id).CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
                 await _azureStorage.GetBlobContainerClient(id).CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
                 var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
                 var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
+                await _dingDing.SendBotMsg($"{schools.ToJsonString()}\n{defaultschool}",GroupNames.醍摩豆服務運維群組);
                 return Ok(new { location = _option.Location, auth_token, blob_uri, blob_sas, schools, defaultschool, courses, total, tsize });
                 return Ok(new { location = _option.Location, auth_token, blob_uri, blob_sas, schools, defaultschool, courses, total, tsize });
 
 
             }
             }