diff --git a/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java b/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java index 1ccc779e11..1730d1fc31 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -1,7 +1,9 @@ package io.metersphere.controller; import com.fasterxml.jackson.core.JsonProcessingException; +import io.metersphere.commons.utils.HttpHeaderUtils; import io.metersphere.dto.TestPlanCaseDTO; +import io.metersphere.plan.dto.TestPlanExtReportDTO; import io.metersphere.plan.dto.TestPlanSimpleReportDTO; import io.metersphere.plan.service.TestPlanReportService; import io.metersphere.plan.service.TestPlanService; @@ -62,4 +64,22 @@ public class ShareController { shareInfoService.validate(shareId, reportId); return testPlanReportService.getShareDbReport(shareInfoService.get(shareId), reportId); } + + @GetMapping("test/plan/ext/report/{shareId}/{reportId}") + public TestPlanExtReportDTO getExtReport(@PathVariable String shareId, @PathVariable String reportId) throws JsonProcessingException { + shareInfoService.validate(shareId, reportId); + HttpHeaderUtils.runAsUser("admin"); + TestPlanExtReportDTO reportExtInfo = testPlanService.getExtInfoByReportId(reportId); + HttpHeaderUtils.clearUser(); + return reportExtInfo; + } + + @GetMapping("test/plan/ext/plan/{shareId}/{planId}") + public TestPlanExtReportDTO getExtPlan(@PathVariable String shareId, @PathVariable String planId) throws JsonProcessingException { + shareInfoService.validate(shareId, planId); + HttpHeaderUtils.runAsUser("admin"); + TestPlanExtReportDTO reportExtInfo = testPlanService.getExtInfoByPlanId(planId); + HttpHeaderUtils.clearUser(); + return reportExtInfo; + } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java b/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java index 971a412814..191e495031 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/wapper/UserService.java @@ -19,6 +19,10 @@ public class UserService { UserMapper userMapper; public UserDTO.PlatformInfo getCurrentPlatformInfo(String workspaceId) { + return JSON.parseObject(getCurrentPlatformInfoStr(workspaceId), UserDTO.PlatformInfo.class); + } + + public String getCurrentPlatformInfoStr(String workspaceId) { User user = userMapper.selectByPrimaryKey(SessionUtils.getUserId()); if (user == null) { return null; @@ -32,11 +36,6 @@ public class UserService { if (platformInfo == null) { return null; } - return JSON.parseObject(JSON.toJSONString(platformInfo), UserDTO.PlatformInfo.class); - } - - public String getCurrentPlatformInfoStr(String workspaceId) { - UserDTO.PlatformInfo currentPlatformInfo = getCurrentPlatformInfo(workspaceId); - return currentPlatformInfo == null ? null : JSON.toJSONString(currentPlatformInfo); + return JSON.toJSONString(platformInfo); } } 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 ed209ce08e..187e587abd 100644 --- a/test-track/frontend/src/api/remote/plan/test-plan.js +++ b/test-track/frontend/src/api/remote/plan/test-plan.js @@ -315,11 +315,21 @@ export function testPlanLoadCaseEditStatus(planId) { export function getTestPlanExtReport(planId, reportId) { if (reportId) { - return get('/test/plan/ext/report/' + reportId); + return get(BASE_URL + 'ext/report/' + reportId); } else if (planId) { - return get('/test/plan/ext/plan/' + planId); + return get(BASE_URL + 'ext/plan/' + planId); } else { - return {}; + return new Promise(() => {}); + } +} + +export function getShareTestPlanExtReport(shareId, planId, reportId) { + if (reportId) { + return get('/share' + BASE_URL + `ext/report/${shareId}/${reportId}`); + } else if (planId) { + return get('/share' + BASE_URL + `ext/plan/${shareId}/${planId}`); + } else { + return new Promise(() => {}); } } 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 d17723948f..a36731d125 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 @@ -36,7 +36,7 @@ import { getShareTestPlanReportContent, getTestPlanReport, getTestPlanReportContent, - getTestPlanExtReport + getTestPlanExtReport, getShareTestPlanExtReport } from "@/api/remote/plan/test-plan"; import TestPlanApiReport from "@/business/plan/view/comonents/report/detail/TestPlanApiReport"; import TestPlanUiReport from "@/business/plan/view/comonents/report/detail/TestPlanUiReport"; @@ -187,10 +187,19 @@ export default { }); } } - getTestPlanExtReport(this.planId, this.reportId).then((response) => { - this.runMode = response.data.runMode; - this.resourcePool = response.data.resourcePool; - }) + if (!this.isTemplate) { + if (this.isShare) { + getShareTestPlanExtReport(this.shareId, this.planId, this.reportId).then((response) => { + this.runMode = response.data.runMode; + this.resourcePool = response.data.resourcePool; + }); + } else { + getTestPlanExtReport(this.planId, this.reportId).then((response) => { + this.runMode = response.data.runMode; + this.resourcePool = response.data.resourcePool; + }); + } + } }, getDefaultConfig(report) { let dbConfig = null;