From 0d65bdc8ff9fdb7212bb57fd97a115412ba982b1 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 29 Nov 2021 16:09:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DSQL=E8=AF=B7=E6=B1=82=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=90=8E=E7=94=A8=E4=BE=8B=E5=8F=98=E9=87=8F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008389 --user=赵勇 【github#7532】接口定义中,选择SQL,创建接口,自定义变量修改后,会把原有case的内容全部清空 https://www.tapd.cn/55049933/s/1076029 --- .../api/service/ApiDefinitionService.java | 12 +- .../scenario/ApiScenarioVariables.vue | 26 +-- .../components/ApiScenarioVariables.vue | 180 +++++++++--------- .../components/EditCompleteContainer.vue | 5 - 4 files changed, 117 insertions(+), 106 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 8eb0f3aa9a..bc34ce8c34 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -514,11 +514,13 @@ public class ApiDefinitionService { } this.setModule(test); apiDefinitionMapper.updateByPrimaryKeySelective(test); - // 同步修改用例 - List ids = new ArrayList<>(); - ids.add(request.getId()); - apiTestCaseService.updateByApiDefinitionId(ids, test.getPath(), test.getMethod(), test.getProtocol()); - //saveFollows(test.getId(), request.getFollows()); + + // 同步修改用例路径 + if (StringUtils.equals(test.getProtocol(), "HTTP")) { + List ids = new ArrayList<>(); + ids.add(request.getId()); + apiTestCaseService.updateByApiDefinitionId(ids, test.getPath(), test.getMethod(), test.getProtocol()); + } return test; } diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue index 8c7f0947b0..50dd810124 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue @@ -56,22 +56,26 @@ }, methods: { remove: function (index) { - this.items.splice(index, 1); - this.$emit('change', this.items); + if(this.items) { + this.items.splice(index, 1); + this.$emit('change', this.items); + } }, change: function () { let isNeedCreate = true; let removeIndex = -1; - this.items.forEach((item, index) => { - if (!item.name && !item.value) { - // 多余的空行 - if (index !== this.items.length - 1) { - removeIndex = index; + if(this.items) { + this.items.forEach((item, index) => { + if (!item.name && !item.value) { + // 多余的空行 + if (index !== this.items.length - 1) { + removeIndex = index; + } + // 没有空行,需要创建空行 + isNeedCreate = false; } - // 没有空行,需要创建空行 - isNeedCreate = false; - } - }); + }); + } if (isNeedCreate) { this.items.push(new KeyValue({enable: true})); } diff --git a/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue b/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue index c692d6be57..c6654488a1 100644 --- a/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue +++ b/frontend/src/business/components/api/definition/components/ApiScenarioVariables.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue b/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue index 60ff7c46a5..4c2931e1fe 100644 --- a/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue +++ b/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue @@ -78,12 +78,10 @@
-
-
@@ -263,9 +261,6 @@ export default { this.$emit("refresh"); }, changeTab(tabType) { - if (this.$refs.apiConfig) { - this.$refs.apiConfig.handleSave(); - } this.refreshButtonActiveClass(tabType); }, removeListener() {