Li 2 роки тому
батько
коміт
97e9cfb44a
1 змінених файлів з 11 додано та 15 видалено
  1. 11 15
      TEAMModelBI/Controllers/BISchool/SchoolController.cs

+ 11 - 15
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -91,20 +91,15 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
                 {
                     if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
-                    {
                         pageSize = tempPageSize;
-                    }
                 }
                 //是否需要进行分页查询,默认不分页
                 bool iscontinuation = false;
                 if (pageSize != null && pageSize.Value > 0)
-                {
                     iscontinuation = true;
-                }
+
                 if (jsonElement.TryGetProperty("contToken", out JsonElement ContToken))
-                {
                     pageToken = ContToken.GetString();
-                }
 
 
                 StringBuilder sqltxt = new($"SELECT c.id,c.name,c.schoolCode,c.province,c.city,c.dist,c.picture,c.period,c.areaId,c.standard,c.manyAreas FROM c");
@@ -196,9 +191,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //jsonElement.TryGetProperty("site", out JsonElement site); //分开部署,就不需要,一站多用时,取消注释
                 var isManyArea = false;
                 if (!string.IsNullOrEmpty($"{isDefault}"))
-                {
                     isManyArea = true;
-                }
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
                 List<string> schoolCodes = _schoolCode.ToObject<List<string>>();
@@ -793,17 +786,20 @@ namespace TEAMModelBI.Controllers.BISchool
         [HttpPost("del-manage")]
         public async Task<IActionResult> DelSchoolManage(JsonElement jsonElement)
         {
+            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();
             //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
 
             List<string> scIds = _scIds.ToObject<List<string>>();
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            var tableClient = _azureStorage.GetCloudTableClient();
+            var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
             ////分开部署,就不需要,一站多用时,取消注释
             //if ($"{site}".Equals(BIConst.Global))
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             List<string> existScId = new();
-
+            StringBuilder strMsg = new($"{_tmdName}【{_tmdId}】管理员账户将{tmdId}的账户移除学校:");
             SchoolTeacher scTeacher = null;
             foreach (var scId in scIds)
             {
@@ -815,6 +811,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     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
@@ -824,6 +821,9 @@ namespace TEAMModelBI.Controllers.BISchool
                     existScId.Add(scId);
             }
 
+            //保存操作记录
+            await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "schoolTeacher-updatee", strMsg.ToString(), _dingDing, httpContext: HttpContext);
+
             return Ok(new { state = RespondCode.Ok, existScId });
         }
 
@@ -1128,17 +1128,13 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
                     if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
-                    {
                         schoolInfo.serial = serial.ToObject<List<ProductSumInfos>>();
-                    }
+
                     if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
-                    {
                         schoolInfo.service = service.ToObject<List<ProductSumInfos>>();
-                    }
+
                     if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
-                    {
                         schoolInfo.hard = hard.ToObject<List<SchoolProductSumDataHard>>();
-                    }
                 }
 
                 schoolInfo.assists = await CommonFind.FindSchoolRoles(cosmosClient, schoolInfo.id, "assist");