From 254e0d4959718e568677c54f6275ad7f36054028 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 26 Dec 2022 10:30:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A=E5=88=86?= =?UTF-8?q?=E4=BA=AB=EF=BC=8C=E6=97=A0=E6=B3=95=E5=B1=95=E7=A4=BA=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=A8=A1=E5=BC=8F=E5=92=8C=E8=B5=84=E6=BA=90=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021013 --user=陈建星 [测试跟踪]测试跟踪-报告-历史报告分享后打开链接提示Network Error https://www.tapd.cn/55049933/s/1319228 --bug=1021103 --user=陈建星 【测试跟踪】测试报告-导出/分享的报告-不显示运行模式和资源池 https://www.tapd.cn/55049933/s/1319227 --- .../controller/ShareController.java | 20 +++++++++++++++++++ .../service/wapper/UserService.java | 11 +++++----- .../frontend/src/api/remote/plan/test-plan.js | 16 ++++++++++++--- .../report/detail/TestPlanReportContent.vue | 19 +++++++++++++----- 4 files changed, 52 insertions(+), 14 deletions(-) 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;