Pārlūkot izejas kodu

Merge branch 'PL/develop-BI' into develop

Li 2 gadi atpakaļ
vecāks
revīzija
bb0041312a

+ 1 - 1
TEAMModelBI/Controllers/BINormal/BatchAreaController.cs

@@ -74,7 +74,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 jsonElement.TryGetProperty("name", out JsonElement name);
                 //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
 
-                int? pageSize = null;      //默认不指定返回大小        
+                int? pageSize = 100;      //默认不指定返回大小        
                 string continuationToken = string.Empty;     //返给前端分页token           
                 string pageToken = default;//接受前端的分页Tolen
                 bool iscontinuation = false;//是否需要进行分页查询,默认不分页

+ 16 - 2
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -670,6 +670,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 jsonElement.TryGetProperty("tmdPic", out JsonElement picture);
                 if (!jsonElement.TryGetProperty("scId", out JsonElement schoolId)) return BadRequest();
                 if (!jsonElement.TryGetProperty("scName", out JsonElement schoolName)) return BadRequest();
+                jsonElement.TryGetProperty("scAreaId", out JsonElement scAreaId);
                 jsonElement.TryGetProperty("scPic", out JsonElement scpicture);
                 //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
                 var cosmosClient = _azureCosmos.GetCosmosClient();
@@ -683,6 +684,19 @@ namespace TEAMModelBI.Controllers.BISchool
                 //    blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
                 //}
                 StringBuilder strMsg = new($"{_tmdName}【{_tmdId}】账户将{tmdName}【{tmdId}】");
+                string areaId = null;
+                if (string.IsNullOrEmpty($"{scAreaId}"))
+                {
+                    var resScInfo = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
+
+                    if (resScInfo.Status == 200)
+                    {
+                        using var tchJson = await JsonDocument.ParseAsync(resScInfo.ContentStream);
+                        School scInfo = tchJson.ToObject<School>();
+                        areaId = scInfo.areaId;
+                    }else areaId = $"{scAreaId}";
+                }
+                else { areaId = $"{scAreaId}"; }
 
                 Teacher teacher = null;
                 SchoolTeacher schoolTeacher = null;
@@ -695,7 +709,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
                     if (existArea == null)
                     {
-                        teacher.schools.Add(new Teacher.TeacherSchool { schoolId = $"{schoolId}", name = $"{schoolName}", status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = string.IsNullOrEmpty($"{scpicture}") ? "" : $"{scpicture}", areaId = "" });
+                        teacher.schools.Add(new Teacher.TeacherSchool { schoolId = $"{schoolId}", name = $"{schoolName}", status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = string.IsNullOrEmpty($"{scpicture}") ? "" : $"{scpicture}", areaId = areaId });
                         teacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
                         strMsg.Append($"账户基础信息添加学校,");
                     }
@@ -710,7 +724,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     teacher.size = 1;
                     teacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                     //教师存在,在该教师信息中添加要管理的学校信息
-                    teacher.schools.Add(new Teacher.TeacherSchool { schoolId = $"{schoolId}", name = $"{schoolName}", status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = string.IsNullOrEmpty($"{scpicture}") ? "" : $"{scpicture}", areaId = "" });
+                    teacher.schools.Add(new Teacher.TeacherSchool { schoolId = $"{schoolId}", name = $"{schoolName}", status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = string.IsNullOrEmpty($"{scpicture}") ? "" : $"{scpicture}", areaId = areaId });
                     teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
                     strMsg.Append($"添加基础信息,并添加学校");
                 }