Browse Source

[BI]刪除第三方企業API
[IES5]字串變更

jeff 1 year ago
parent
commit
2353406fcf

+ 55 - 10
TEAMModelBI/Controllers/BINormal/BusinessConfigController.cs

@@ -48,12 +48,12 @@ namespace TEAMModelBI.Controllers.BINormal
             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);
-                tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
-                blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
-            }
+            //if ($"{site}".Equals(BIConst.Global))
+            //{
+            //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
+            //    tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
+            //    blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
+            //}
             string salt = Utils.CreatSaltString(8);
             List<BizUsers> bizUsers = new();
             string type = "";
@@ -133,15 +133,12 @@ namespace TEAMModelBI.Controllers.BINormal
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [ProducesDefaultResponseType]
+        [AuthToken(Roles = "admin,rdc,assist")]
         [HttpPost("get-infos")]
         public async Task<IActionResult> GetInfos(JsonElement jsonElement) 
         {
             jsonElement.TryGetProperty("id", out JsonElement id);
-            //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
             var cosmosClient = _azureCosmos.GetCosmosClient();
-            ////分开部署,就不需要,一站多用时,取消注释
-            //if ($"{site}".Equals(BIConst.Global))
-            //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
             StringBuilder sqlTxt = new("select value(c) from c");
             if (!string.IsNullOrEmpty($"{id}"))
             {
@@ -156,6 +153,54 @@ namespace TEAMModelBI.Controllers.BINormal
 
             return Ok(new { state = RespondCode.Ok, businesses });
         }
+        /// <summary>
+        /// 刪除企业信息列表
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "admin,rdc,assist")]
+        [HttpPost("del-info")]
+        public async Task<IActionResult> DelInfo(JsonElement jsonElement)
+        {
+            try
+            {
+                jsonElement.TryGetProperty("id", out JsonElement id);
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                var tableClient = _azureStorage.GetCloudTableClient();
+                var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
+                //企業聯絡人 刪除該企業聯絡資訊
+                List<string> bizUsersIdList = new List<string>();
+                StringBuilder sql = new($"SELECT VALUE c.id FROM c JOIN r IN c.relation WHERE r.bizId = '{id}'");
+                await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<string>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") })) {
+                    bizUsersIdList.Add(items);
+                }
+                if(bizUsersIdList.Count > 0)
+                {
+                    string bizUsersIdListStr = JsonSerializer.Serialize(bizUsersIdList);
+                    sql = new($"SELECT * FROM c WHERE ARRAY_CONTAINS({bizUsersIdListStr}, c.id, true)");
+                    await foreach (BizUsers item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+                    {
+                        item.relation.RemoveAll(r => r.bizId == $"{id}");
+                        await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(item, item.id, new PartitionKey("BizUsers"));
+                    }
+                }
+                //刪除企業
+                await cosmosClient.GetContainer("TEAMModelOS", "Normal").DeleteItemStreamAsync($"{id}", new PartitionKey("BizConfig"));
+                //Log
+                StringBuilder strMsg = new();
+                strMsg.Append($"删除企业基础信息。删除ID:{id}");
+                string type = "bizconfig-del";
+                await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, type, strMsg.ToString(), _dingDing, httpContext: HttpContext);
+
+                return Ok(new { state = RespondCode.Ok, id = id });
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"BI,{_option.Location} bizconfig/del-info \n {ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
 
         /// <summary>
         /// 重置秘钥    //已对接

+ 20 - 20
TEAMModelOS/ClientApp/public/lang/en-US.js

@@ -15,7 +15,7 @@ const LANG_EN_US = {
         off: 'Off',
         toProvince: '推送省平臺',
         noData: '當前條件下未匹配到教師數據',
-        noGroup: '未分組',
+        noGroup: 'Ungrouped',
         offline: 'School Study',
         online: 'Online Study',
         ability: 'Certified Material',
@@ -2205,11 +2205,11 @@ const LANG_EN_US = {
             error: "Failed to delete",
             noData: "No data yet",
             like: 'Like',
-            editTopic: 'Edit topic',
-            releaseTopic: 'Release topic',
-            deleteTopic: 'Delete topic',
-            deleteTopic1: 'Confirm to delete?',
-            deleteTopic2: 'Delete response',
+            editTopic: 'Edit Topic',
+            releaseTopic: 'Release Topic',
+            deleteTopic: 'Delete Topic',
+            deleteTopic1: 'Confirm to delete ',
+            deleteTopic2: 'Delete Response',
             deleteTopic3: 'Are you sure to delete this response?',
         },
         // 线上研修
@@ -5735,8 +5735,8 @@ const LANG_EN_US = {
             trainSystem: 'Research Platform',
             artExam: 'Assessment Activity',
             artExam1: 'Assessment Evaluation',
-            iotBoard: 'Smart Classes IoT Dashboard',
-            areaIotboard: 'Smart Classes IoT Dashboard'
+            iotBoard: 'IoT Smart Classroom Dashboard',
+            areaIotboard: 'IoT Smart Classroom Dashboard'
         },
         compt: {
             cusWare: 'Teaching Material',
@@ -7422,39 +7422,39 @@ const LANG_EN_US = {
         subjectTitle: 'Subject Distribution',
     },
     schoolIot: {
-        title: 'Auto Collection (IoT) Dashboard of Scholl Smart Classes',
+        title: 'Automated (IoT) School Smart Classroom Dashboard',
         basics: {
             classnums: 'Used Classrooms',
-            classTotals: 'Activate Licenses',
+            classTotals: 'Activated Licenses',
             teachnums: 'Used Teachers',
             teachTotals: 'Total Enrolled Teachers',
-            studentnums: 'Student Participation Times',
+            studentnums: 'Participated Student',
             studentTotals: 'Total Enrolled Students',
-            studentTime: 'Accumulated Hours of All Student Participation',
-            classroomTotal: 'Total Class Periods',
-            classroomTime: 'Total Hours of Class Periods',
+            studentTime: 'Total Accumulated Time of Student Participation',
+            classroomTotal: 'Total Lesson Periods',
+            classroomTime: 'Total Time of All Lessons',
         },
         classrooming: {
-            title: 'Application Achievements in Class ',
+            title: 'Lesson Statistics',
             taskNums: 'Total Tasks',
             productionNums: 'Total Works',
             topicNums: 'Total Questions',
             interactionNums: 'Total Interactions',
         },
         device: {
-            title: 'Device Usage Status',
+            title: 'Device Statistics',
             deviceTotal: 'Total Devices',
             deviceOnline: 'Used Devices',
         },
         lessons: {
-            title: 'Class Periods and Application Weekly Chart',
-            classroomNums: 'Class Periods',
+            title: 'Lesson and Application History Chart',
+            classroomNums: 'Lessons',
             productionNums: 'Works',
             topicNums: 'Questions',
             interactionNums: 'Interactions',
         },
         morphologyClass: {
-            title: 'Learning Pattern Chart',
+            title: 'Lesson Type Statistics',
             cooperation: 'Cooperative',
             interaction: 'Interactive',
             task: 'Task',
@@ -7463,7 +7463,7 @@ const LANG_EN_US = {
         }
     },
     areaIot: {
-        title: 'Auto Collection (IoT) Dashboard of Distrcit Smart Classes',
+        title: 'Automated (IoT) Distrcit Smart Classroom Dashboard',
         classrank: {
             title: 'Lesson Record Statistics',
             rank: 'Rank',