diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java index 71106482fe..2a03aea7c8 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -376,8 +376,13 @@ public class TestPlanController { testPlanService.resetStatus(planId); } - @GetMapping("/ext/report/{planId}") - public TestPlanExtReportDTO getExtReport(@PathVariable String planId) throws JsonProcessingException { - return testPlanService.getExtReport(planId); + @GetMapping("/ext/report/{reportId}") + public TestPlanExtReportDTO getExtReport(@PathVariable String reportId) throws JsonProcessingException { + return testPlanService.getExtInfoByReportId(reportId); + } + + @GetMapping("/ext/plan/{planId}") + public TestPlanExtReportDTO getExtPlan(@PathVariable String planId) throws JsonProcessingException { + return testPlanService.getExtInfoByPlanId(planId); } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 386f3020aa..88c8eccd62 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -1049,7 +1049,7 @@ public class TestPlanReportService { TestPlanService testPlanService = CommonBeanFactory.getBean(TestPlanService.class); TestPlanExtReportDTO extReport = null; try { - extReport = testPlanService.getExtReportByReportId(reportId); + extReport = testPlanService.getExtInfoByReportId(reportId); } catch (JsonProcessingException e) { throw new RuntimeException(e); } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index 01d18fb368..c9c8199acf 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -1388,7 +1388,7 @@ public class TestPlanService { public void exportPlanReport(String planId, String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { TestPlanSimpleReportDTO report = buildPlanReport(planId, true); report.setLang(lang); - TestPlanExtReportDTO extReport = getExtReport(planId); + TestPlanExtReportDTO extReport = getExtInfoByPlanId(planId); if(extReport != null) { BeanUtils.copyBean(report, extReport); } @@ -1397,7 +1397,7 @@ public class TestPlanService { public void exportPlanDbReport(String reportId, String lang, HttpServletResponse response) throws UnsupportedEncodingException, JsonProcessingException { TestPlanSimpleReportDTO report = testPlanReportService.getReport(reportId); - TestPlanExtReportDTO extReport = getExtReportByReportId(reportId); + TestPlanExtReportDTO extReport = getExtInfoByReportId(reportId); if(extReport != null) { BeanUtils.copyBean(report, extReport); } @@ -1967,11 +1967,7 @@ public class TestPlanService { this.deleteTestPlans(ids); } - public TestPlanExtReportDTO getExtReport(String planId) throws JsonProcessingException { - String reportId = testPlanReportService.getLastReportByPlanId(planId); - if(StringUtils.isEmpty(reportId)){ - return null; - } + public TestPlanExtReportDTO getExtInfoByReportId(String reportId) throws JsonProcessingException { TestPlanExtReportDTO testPlanExtReportDTO = new TestPlanExtReportDTO(); Set serviceIdSet = DiscoveryUtil.getServiceIdSet(); if (serviceIdSet.contains(MicroServiceName.API_TEST)) { @@ -1992,7 +1988,7 @@ public class TestPlanService { return testPlanExtReportDTO; } } - return null; + return testPlanExtReportDTO; } private void convertEnvConfig(String envConfig, TestPlanExtReportDTO testPlanExtReportDTO) throws JsonProcessingException { @@ -2017,7 +2013,11 @@ public class TestPlanService { testPlanExtReportDTO.setResourcePool(testResourcePool == null ? null : testResourcePool.getName()); } - public TestPlanExtReportDTO getExtReportByReportId(String reportId) throws JsonProcessingException { + public TestPlanExtReportDTO getExtInfoByPlanId(String planId) throws JsonProcessingException { + String reportId = testPlanReportService.getLastReportByPlanId(planId); + if(StringUtils.isEmpty(reportId)){ + return null; + } TestPlanExtReportDTO testPlanExtReportDTO = new TestPlanExtReportDTO(); Set serviceIdSet = DiscoveryUtil.getServiceIdSet(); if (serviceIdSet.contains(MicroServiceName.API_TEST)) { @@ -2038,6 +2038,6 @@ public class TestPlanService { return testPlanExtReportDTO; } } - return null; + return testPlanExtReportDTO; } } diff --git a/test-track/frontend/src/api/remote/plan/test-plan.js b/test-track/frontend/src/api/remote/plan/test-plan.js index 200c08938f..bd663bd004 100644 --- a/test-track/frontend/src/api/remote/plan/test-plan.js +++ b/test-track/frontend/src/api/remote/plan/test-plan.js @@ -309,9 +309,13 @@ export function testPlanLoadCaseEditStatus(planId) { return post(BASE_URL + `edit/status/${planId}`, new Promise(() => {})); } -export function getTestPlanExtReport(planId) { - if (planId) { - return get('/test/plan/ext/report/' + planId); +export function getTestPlanExtReport(planId, reportId) { + if (reportId) { + return get('/test/plan/ext/report/' + reportId); + } else if (planId) { + return get('/test/plan/ext/plan/' + planId); + } else { + return {}; } } diff --git a/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue b/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue index b11149d0b4..d17723948f 100644 --- a/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue +++ b/test-track/frontend/src/business/plan/view/comonents/report/detail/TestPlanReportContent.vue @@ -71,13 +71,13 @@ export default { isDb: Boolean, shareId: String, reportId: String, - runMode: String, - resourcePool: String, needMoveBar: Boolean }, data() { return { report: {}, + runMode: '', + resourcePool: '', loading: false, shareUrl: '' }; @@ -187,8 +187,7 @@ export default { }); } } - - getTestPlanExtReport(this.planId).then((response) => { + getTestPlanExtReport(this.planId, this.reportId).then((response) => { this.runMode = response.data.runMode; this.resourcePool = response.data.resourcePool; })