diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 2c73ee947e..5e1f54af8e 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -254,4 +254,9 @@ public class TestPlanController { apiAutomationService.updateSchedule(schedule); return schedule; } + + @GetMapping("/have/exec/case/{id}") + public boolean haveExecCase(@PathVariable String id) { + return testPlanService.haveExecCase(id); + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 59637d696b..c280708572 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1917,4 +1917,28 @@ public class TestPlanService { testPlan.setReportConfig(testPlanDTO.getReportConfig()); testPlanMapper.updateByPrimaryKeySelective(testPlan); } + + public boolean haveExecCase(String id) { + if (StringUtils.isBlank(id)) { + return false; + } + TestPlanApiCaseExample apiCaseExample = new TestPlanApiCaseExample(); + apiCaseExample.createCriteria().andTestPlanIdEqualTo(id); + List testPlanApiCases = testPlanApiCaseMapper.selectByExample(apiCaseExample); + if (!CollectionUtils.isEmpty(testPlanApiCases)) { + return true; + } + + TestPlanApiScenarioExample apiScenarioExample = new TestPlanApiScenarioExample(); + apiScenarioExample.createCriteria().andTestPlanIdEqualTo(id); + List testPlanApiScenarios = testPlanApiScenarioMapper.selectByExample(apiScenarioExample); + if (!CollectionUtils.isEmpty(testPlanApiScenarios)) { + return true; + } + + TestPlanLoadCaseExample loadCaseExample = new TestPlanLoadCaseExample(); + loadCaseExample.createCriteria().andTestPlanIdEqualTo(id); + List testPlanLoadCases = testPlanLoadCaseMapper.selectByExample(loadCaseExample); + return !CollectionUtils.isEmpty(testPlanLoadCases); + } } diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index 591c935f8e..5f47238931 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -480,7 +480,14 @@ export default { }, handleRun(row) { this.currentPlanId = row.id; - this.$refs.runMode.open('API'); + this.$get("/test/plan/have/exec/case/" + row.id, res => { + const haveExecCase = res.data; + if (haveExecCase) { + this.$refs.runMode.open('API'); + } else { + this.$router.push('/track/plan/view/' + row.id); + } + }) }, _handleRun(config) { let {mode, reportType, onSampleError, runWithinResourcePool, resourcePoolId, envMap} = config;