From 3774b91928a71c89ceccf3bb6c9bc04e263bfffc Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 20 Jan 2022 13:53:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E7=BC=96=E5=86=99=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/sampler/MsJDBCSampler.java | 10 +++++----- .../dto/definition/request/sampler/MsTCPSampler.java | 10 +++++----- .../metersphere/api/service/ApiAutomationService.java | 10 ++++++++++ .../scenario/component/ApiScenarioComponent.vue | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index 1e91ae1055..176cbe0b62 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -155,12 +155,12 @@ public class MsJDBCSampler extends MsTestElement { } //处理全局前后置脚本(步骤内) - String enviromentId = this.getEnvironmentId(); - if (enviromentId == null) { - enviromentId = this.useEnvironment; + String environmentId = this.getEnvironmentId(); + if (environmentId == null) { + environmentId = this.useEnvironment; } //根据配置将脚本放置在私有脚本之前 - JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.JDBC.name(), enviromentId, config, false); + JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.JDBC.name(), environmentId, config, false); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { @@ -168,7 +168,7 @@ public class MsJDBCSampler extends MsTestElement { }); } //根据配置将脚本放置在私有脚本之后 - JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.JDBC.name(), enviromentId, config, true); + JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.JDBC.name(), environmentId, config, true); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index cddc101bfb..78f52f7486 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -150,12 +150,12 @@ public class MsTCPSampler extends MsTestElement { } //处理全局前后置脚本(步骤内) - String enviromentId = this.getEnvironmentId(); - if (enviromentId == null) { - enviromentId = this.useEnvironment; + String environmentId = this.getEnvironmentId(); + if (environmentId == null) { + environmentId = this.useEnvironment; } //根据配置将脚本放置在私有脚本之前 - JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.TCP.name(), enviromentId, config, false); + JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.TCP.name(), environmentId, config, false); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { @@ -163,7 +163,7 @@ public class MsTCPSampler extends MsTestElement { }); } //根据配置将脚本放置在私有脚本之后 - JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.TCP.name(), enviromentId, config, true); + JMeterScriptUtil.setScript(envConfig, samplerHashTree, GlobalScriptFilterRequest.TCP.name(), environmentId, config, true); } private void addItemHashTree(MsTestElement element, HashTree samplerHashTree, ParameterConfig config) { 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 d5c1bd341d..d70eb0a322 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -673,6 +673,11 @@ public class ApiAutomationService { element.put("enable", enable); element.put("environmentEnable", environmentEnable); hashTree.set(i, element); + } else { + if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) { + element.put("enable", false); + element.put("num", ""); + } } } if (element.containsKey("hashTree")) { @@ -695,6 +700,11 @@ public class ApiAutomationService { element.put("enable", enable); element.put("environmentEnable", environmentEnable); element.put("num", scenarioWithBLOBs.getNum()); + } else { + if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) { + element.put("enable", false); + element.put("num", ""); + } } } if (element != null && element.containsKey("hashTree")) { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index fe72ef4b6f..6f3e2748d0 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -110,7 +110,7 @@ export default { this.isShowNum = true; this.getWorkspaceId(this.scenario.projectId); } else { - this.isSameSpace = false; + this.isShowNum = false; } if (!this.scenario.projectId) { this.scenario.projectId = getCurrentProjectID();