refactor(接口自动化): 列表触发执行场景前进行环境检查

This commit is contained in:
shiziyuan9527 2021-11-30 19:32:03 +08:00 committed by shiziyuan9527
parent 386d124c86
commit d12027005f
4 changed files with 23 additions and 4 deletions

View File

@ -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<String> getFollows(@PathVariable String scenarioId) {
return apiAutomationService.getFollows(scenarioId);

View File

@ -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<String> getFollows(String scenarioId) {
List<String> result = new ArrayList<>();
if (StringUtils.isBlank(scenarioId)) {

View File

@ -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);
})
}
});
},

View File

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