From fd3c8052fc2e5745f6a14758452990c14a1b2503 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 14 Dec 2020 17:35:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C=E7=9B=B8=E5=85=B3=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/service/ApiAutomationService.java | 2 +- .../components/api/automation/scenario/EditApiScenario.vue | 4 ++++ .../components/api/definition/components/ApiList.vue | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 9d652d367f..90c436f519 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -248,7 +248,7 @@ public class ApiAutomationService { JSONObject element = JSON.parseObject(item.getScenarioDefinition()); MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 - if (StringUtils.isNotEmpty(element.getString("hashTree"))) { + if (element!= null && StringUtils.isNotEmpty(element.getString("hashTree"))) { LinkedList elements = mapper.readValue(element.getString("hashTree"), new TypeReference>() { }); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index ea19ba2c39..79d369b596 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -455,6 +455,10 @@ addScenario(arr) { if (arr && arr.length > 0) { arr.forEach(item => { + if (item.id === this.currentScenario.id) { + this.$error("不能引用或复制自身!"); + return; + } item.enable === undefined ? item.enable = true : item.enable; this.scenarioDefinition.push(item); }) diff --git a/frontend/src/business/components/api/definition/components/ApiList.vue b/frontend/src/business/components/api/definition/components/ApiList.vue index 4862905580..4c831ab263 100644 --- a/frontend/src/business/components/api/definition/components/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/ApiList.vue @@ -306,7 +306,12 @@ }, handleTestCase(api) { this.selectApi = api; - let request = JSON.parse(api.request); + let request = {}; + if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { + request = api.request; + } else { + request = JSON.parse(api.request); + } if (!request.hashTree) { request.hashTree = []; }