From 29c8d6031e4c3f4182f5bf2323a35b2188552979 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 17 Aug 2022 17:26:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E5=90=8C=E6=AD=A5=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015900 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015897 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015882 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015879 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015859 --- .../api/controller/ApiTestCaseController.java | 5 +++++ .../api/service/ApiTestCaseService.java | 15 ++++++++++++++- .../base/mapper/ext/ExtApiTestCaseMapper.xml | 1 + .../java/io/metersphere/dto/ProjectConfig.java | 2 +- .../definition/components/case/ApiCaseItem.vue | 14 +++++++++++++- .../project/menu/appmanage/AppManage.vue | 2 +- frontend/src/i18n/en-US.js | 2 +- frontend/src/i18n/zh-CN.js | 2 +- frontend/src/i18n/zh-TW.js | 2 +- 9 files changed, 38 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java index 5a96225a71..35242260b7 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -233,4 +233,9 @@ public class ApiTestCaseController { public void saveFollows(@PathVariable String testId, @RequestBody List follows) { apiTestCaseService.saveFollows(testId, follows); } + + @GetMapping("/be/cited/scenario/{testId}") + public Integer getCitedScenarioCount(@PathVariable String testId) { + return apiTestCaseService.getCitedScenarioCount(testId); + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 4d5b3e23de..ef201bd6b3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -125,6 +125,8 @@ public class ApiTestCaseService { private ApiCaseBatchSyncService apiCaseSyncService; @Resource private ApiTestCaseSyncService apiTestCaseSyncService; + @Resource + private ApiScenarioReferenceIdMapper apiScenarioReferenceIdMapper; private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR; @@ -1299,7 +1301,7 @@ public class ApiTestCaseService { if (!request.isToBeUpdated() || StringUtils.isBlank(request.getProjectId())) { return; } - + Long toBeUpdatedTime = this.getToBeUpdatedTime(request.getProjectId()); if (toBeUpdatedTime != null) { request.setToBeUpdateTime(toBeUpdatedTime); @@ -1310,4 +1312,15 @@ public class ApiTestCaseService { } request.setStatusList(syncRuleCaseStatus); } + + public Integer getCitedScenarioCount(String testId) { + ApiScenarioReferenceIdExample apiScenarioReferenceIdExample = new ApiScenarioReferenceIdExample(); + apiScenarioReferenceIdExample.createCriteria().andDataTypeEqualTo(ReportTriggerMode.CASE.name()).andReferenceTypeEqualTo(MsTestElementConstants.REF.name()).andReferenceIdEqualTo(testId); + List apiScenarioReferenceIds = apiScenarioReferenceIdMapper.selectByExample(apiScenarioReferenceIdExample); + if (CollectionUtils.isEmpty(apiScenarioReferenceIds)) { + return 0; + } else { + return apiScenarioReferenceIds.size(); + } + } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 77429e4976..115eefa490 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -362,6 +362,7 @@ t1.update_user_id, t1.create_time, t1.update_time, + t1.to_be_updated, t1.num, a.module_id, a.path, diff --git a/backend/src/main/java/io/metersphere/dto/ProjectConfig.java b/backend/src/main/java/io/metersphere/dto/ProjectConfig.java index d38c18fd57..4589141e5c 100644 --- a/backend/src/main/java/io/metersphere/dto/ProjectConfig.java +++ b/backend/src/main/java/io/metersphere/dto/ProjectConfig.java @@ -29,5 +29,5 @@ public class ProjectConfig { private String triggerUpdate; private Boolean openUpdateTime = false; private String openUpdateRuleTime; - private Boolean openUpdateRule = false; + private Boolean openUpdateRule = null; } diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index ec5b743436..4a9de0e737 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -323,7 +323,8 @@ export default { caseSyncRuleRelation: { scenarioCreator: true, showUpdateRule: false, - } + }, + citedScenarioCount: 0, } }, props: { @@ -395,6 +396,7 @@ export default { if (hasLicense()) { this.beforeUpdateRequest = deepClone(this.apiCase.request); this.getSyncRule(); + this.getCitedScenarioCount(); this.$EventBus.$on('showXpackCaseSet', noShowSyncRuleRelation => { this.handleXpackCaseSetChange(noShowSyncRuleRelation); }); @@ -707,6 +709,9 @@ export default { }, validCaseRestChange() { let syncCaseVisible = false; + if (this.citedScenarioCount === 0) { + return false; + } if (this.apiCase.request.headers && this.beforeUpdateRequest.headers) { let submitRequestHeaders = JSON.stringify(this.apiCase.request.headers); let beforeRequestHeaders = JSON.stringify(this.beforeUpdateRequest.headers); @@ -869,6 +874,13 @@ export default { }, handleXpackCaseSetChange(noShowSyncRuleRelation) { this.noShowSyncRuleRelation = noShowSyncRuleRelation + }, + getCitedScenarioCount() { + this.$get('/api/testcase/be/cited/scenario/' + this.apiCase.id, response => { + if (response.data) { + this.citedScenarioCount = response.data; + } + }); } } } diff --git a/frontend/src/business/components/project/menu/appmanage/AppManage.vue b/frontend/src/business/components/project/menu/appmanage/AppManage.vue index 87db9f3fe9..443e1993c5 100644 --- a/frontend/src/business/components/project/menu/appmanage/AppManage.vue +++ b/frontend/src/business/components/project/menu/appmanage/AppManage.vue @@ -427,7 +427,7 @@ export default { this.showSyncTimeSetting = true; } } - this.openUpdateRule = this.config.openUpdateRule + this.openUpdateRule = this.config.openUpdateRule !== false; this.disabledRuleBtn = !this.openUpdateRule } }); diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 32a587724b..0d26c8b73a 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -3414,7 +3414,7 @@ export default { no_show_setting_tip: "After checking, the pop-up window will no longer pop up, and the synchronization and change notification will be performed according to the setting content by default: If you need to change the setting, you can open the setting item in the drop-down option next to the save button。", go_to_api_message: 'Interface API update message notification', go_to_case_message: 'CASE update message notification', - update_case_tip: 'When the CASE changes, the creator of the automation scene referring to the CASE recycles the message reminder in the station' + update_case_tip: 'When the CASE changes, the creator of the automation scene referring to the CASE will receive an in-site message reminder' } } }; diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 1d836211bb..d5d7e94aff 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -3425,7 +3425,7 @@ export default { no_show_setting_tip: "勾选后,不再弹出弹窗,会默认按照设置的内容执行同步和变更通知:如果需要更改设置,可以在保存按钮旁的下拉选项中,打开设置项。", go_to_api_message: '接口API更新消息通知', go_to_case_message: 'CASE更新消息通知', - update_case_tip: '当CASE发生变化时,引用CASE的自动化场景创建人回收到站内消息提醒' + update_case_tip: '当CASE发生变化时,引用CASE的自动化场景创建人会收到站内消息提醒' } } }; diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 2f4766ad86..0dbfeff420 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -3401,7 +3401,7 @@ export default { no_show_setting_tip: "勾選後,不再彈出彈窗,會默認按照設置的內容執行同步和變更通知:如果需要更改設置,可以在保存按鈕旁的下拉選項中,打開設置項。", go_to_api_message: '接口API更新消息通知', go_to_case_message: 'CASE更新消息通知', - update_case_tip: '當CASE發生變化時,引用CASE的自動化場景創建人回收到站內消息提醒' + update_case_tip: '當CASE發生變化時,引用CASE的自動化場景創建人會收到站內消息提醒' } } };