From 1b26df9c2d56b40e2962a4d994246f194e87a04a Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 19 Jun 2024 18:34:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E8=BF=87=E6=9C=9F=E5=88=A0=E9=99=A4=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/TestPlanShareResponse.java | 5 ++++- .../service/TestPlanReportShareService.java | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanShareResponse.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanShareResponse.java index cf5f3ce1ad..b8d894bed0 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanShareResponse.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanShareResponse.java @@ -21,5 +21,8 @@ public class TestPlanShareResponse { private String reportId; @Schema(description = "分享链接是否被删") - private Boolean deleted; + private boolean deleted; + + @Schema(description = "分享链接是否过期") + private boolean expired; } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportShareService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportShareService.java index 57407e17c5..664c277b3a 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportShareService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportShareService.java @@ -31,6 +31,7 @@ import java.util.List; import static io.metersphere.sdk.util.ShareUtil.getTimeMills; @Service +@Transactional(rollbackFor = Exception.class) public class TestPlanReportShareService { @Resource @@ -94,16 +95,28 @@ public class TestPlanReportShareService { * @return 分享信息 */ public TestPlanShareResponse get(String id) { - ShareInfo shareInfo = checkResource(id); TestPlanShareResponse dto = new TestPlanShareResponse(); + ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(id); + // 无分享记录, 过期直接返回 + if (shareInfo == null) { + dto.setExpired(true); + return dto; + } BeanUtils.copyBean(dto, shareInfo); dto.setReportId(new String(shareInfo.getCustomData())); - //检查报告ID是否存在 - dto.setDeleted(false); + // 检查报告ID是否存在 TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(dto.getReportId()); if (testPlanReport == null || testPlanReport.getDeleted()) { dto.setDeleted(true); } + // 报告正常, 校验分享时间是否过期 + if (!dto.isDeleted()) { + try { + validateExpired(shareInfo); + } catch (Exception e) { + dto.setExpired(true); + } + } return dto; }