From 74a987c375b28fab2a4dad731668feb3ef9edc28 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 30 Nov 2021 19:32:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=88=97=E8=A1=A8=E8=A7=A6=E5=8F=91=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=9C=BA=E6=99=AF=E5=89=8D=E8=BF=9B=E8=A1=8C=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/ApiAutomationController.java | 5 +++++ .../api/service/ApiAutomationService.java | 6 ++++++ .../api/automation/scenario/ApiScenarioList.vue | 14 +++++++++++--- .../scenario/component/ApiScenarioComponent.vue | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index 782c281af8..85837936f6 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -364,6 +364,11 @@ public class ApiAutomationController { return apiAutomationService.checkScenarioEnv(request); } + @GetMapping(value = "/checkScenarioEnv/{scenarioId}") + public boolean checkScenarioEnvByScenarioId(@PathVariable String scenarioId) { + return apiAutomationService.checkScenarioEnv(scenarioId); + } + @GetMapping("/follow/{scenarioId}") public List getFollows(@PathVariable String scenarioId) { return apiAutomationService.getFollows(scenarioId); 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 777bea6712..54cef07147 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -3033,6 +3033,12 @@ public class ApiAutomationService { return this.checkScenarioEnv(request, null); } + public boolean checkScenarioEnv(String scenarioId) { + ApiScenarioWithBLOBs apiScenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(scenarioId); + this.setScenarioEnv(apiScenarioWithBLOBs); + return this.checkScenarioEnv(apiScenarioWithBLOBs, null); + } + public List getFollows(String scenarioId) { List result = new ArrayList<>(); if (StringUtils.isBlank(scenarioId)) { diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 0488f7f838..ddca3b8db0 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -1005,9 +1005,17 @@ export default { } this.environmentType = this.currentScenario.environmentType; this.envGroupId = this.currentScenario.environmentGroupId; - this.reportId = getUUID().substring(0, 8); - this.runVisible = true; - this.$set(row, "isStop", true); + + this.$get("/api/automation/checkScenarioEnv/" + this.currentScenario.id, res => { + let data = res.data; + if (!data) { + this.$warning("请为场景选择环境!"); + return false; + } + this.reportId = getUUID().substring(0, 8); + this.runVisible = true; + this.$set(row, "isStop", true); + }) } }); }, 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 5d23b1ace4..a8639ca434 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -177,7 +177,7 @@ export default { this.reload(); }, checkEnv(val) { - this.$post("/api/automation/checkScenarioEnv", {scenarioDefinition: JSON.stringify(this.scenario), projectId: this.projectId}, res => { + this.$get("/api/automation/checkScenarioEnv/" + this.scenario.id, res => { if (this.scenario.environmentEnable && !res.data) { this.scenario.environmentEnable = false; this.$warning("当前场景没有环境,需要先设置自身环境");