From c9e4e32fca0ffc13f4cad6186b6779b0d7d04ee5 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 25 Feb 2021 14:37:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E8=B7=A8=E9=A1=B9=E7=9B=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=85=BC=E5=AE=B9=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 10 +++++++++- .../api/automation/scenario/EditApiScenario.vue | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index ce75db0d61..41c5e1e228 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -15,6 +15,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService; import io.metersphere.base.domain.ApiScenarioWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; import io.metersphere.commons.utils.CommonBeanFactory; +import io.metersphere.commons.utils.SessionUtils; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; @@ -93,7 +94,14 @@ public class MsScenario extends MsTestElement { config.setStep(this.getName()); config.setStepType("SCENARIO"); config.setEnableCookieShare(enableCookieShare); - Map envConfig = new HashMap<>(); + Map envConfig = new HashMap<>(16); + // 兼容历史数据 + if (environmentMap == null || environmentMap.isEmpty()) { + environmentMap = new HashMap<>(16); + if (StringUtils.isNotBlank(environmentId)) { + environmentMap.put(SessionUtils.getCurrentProjectId(), environmentId); + } + } if (environmentMap != null && !environmentMap.isEmpty()) { environmentMap.keySet().forEach(projectId -> { ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index dfc2245677..1035676869 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -922,7 +922,12 @@ export default { let obj = JSON.parse(response.data.scenarioDefinition); if (obj) { this.currentEnvironmentId = obj.environmentId; - this.projectEnvMap = this.objToStrMap(obj.environmentMap); + if (obj.environmentMap) { + this.projectEnvMap = this.objToStrMap(obj.environmentMap); + } else { + // 兼容历史数据 + this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId); + } this.currentScenario.variables = []; let index = 1; if (obj.variables) {