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("当前场景没有环境,需要先设置自身环境");