From 277b406aff553d7a064fcf0c2bf2aec6d2bd6cf0 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 30 Oct 2024 11:31:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E6=B0=B8=E4=B9=85=E6=9C=89=E6=95=88=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1048322 --user=宋昌昌 【接口测试】定义-分享-分享列表-截止时间排序-永久有效应该是最大的值 https://www.tapd.cn/55049933/s/1601843 --- .../api/service/definition/ApiDocShareService.java | 7 ++++++- .../api/controller/ApiDocShareControllerTests.java | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDocShareService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDocShareService.java index eea9f8847e..10f50dcbc1 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDocShareService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDocShareService.java @@ -88,6 +88,7 @@ public class ApiDocShareService { docShare.setCreateTime(System.currentTimeMillis()); docShare.setUpdateUser(currentUser); docShare.setUpdateTime(System.currentTimeMillis()); + docShare.setInvalidTime(request.getInvalidTime() == 0 ? Long.MAX_VALUE : request.getInvalidTime()); apiDocShareMapper.insert(docShare); return docShare; } @@ -104,6 +105,7 @@ public class ApiDocShareService { BeanUtils.copyBean(docShare, request); docShare.setUpdateUser(currentUser); docShare.setUpdateTime(System.currentTimeMillis()); + docShare.setInvalidTime(request.getInvalidTime() == 0 ? Long.MAX_VALUE : request.getInvalidTime()); apiDocShareMapper.updateByPrimaryKeySelective(docShare); return docShare; } @@ -138,7 +140,7 @@ public class ApiDocShareService { public ApiDocShareDetail detail(String id) { ApiDocShare docShare = checkExit(id); ApiDocShareDetail detail = ApiDocShareDetail.builder().allowExport(docShare.getAllowExport()).isPrivate(docShare.getIsPrivate()).build(); - if (docShare.getInvalidTime() == null || docShare.getInvalidTime() == 0) { + if (docShare.getInvalidTime() == null || docShare.getInvalidTime() == Long.MAX_VALUE) { detail.setInvalid(false); } else { detail.setInvalid(docShare.getInvalidTime() < System.currentTimeMillis()); @@ -210,6 +212,9 @@ public class ApiDocShareService { List distinctUpdateUserIds = docShares.stream().map(ApiDocShareDTO::getUpdateUser).distinct().toList(); Map userMap = userToolService.getUserMapByIds(ListUtils.union(distinctCreateUserIds, distinctUpdateUserIds)); docShares.forEach(docShare -> { + if (docShare.getInvalidTime() == Long.MAX_VALUE) { + docShare.setInvalidTime(0L); + } docShare.setInvalid(docShare.getInvalidTime() != null && docShare.getInvalidTime() != 0 && docShare.getInvalidTime() < System.currentTimeMillis()); docShare.setApiShareNum(countApiShare(docShare)); docShare.setCreateUserName(userMap.get(docShare.getCreateUser())); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDocShareControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDocShareControllerTests.java index e9bcd2ca87..a3a1dc5f35 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDocShareControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDocShareControllerTests.java @@ -54,6 +54,7 @@ public class ApiDocShareControllerTests extends BaseTest { request.setIsPrivate(false); request.setPassword("123456"); request.setAllowExport(false); + request.setInvalidTime(0L); MvcResult mvcResult = this.requestPostWithOk(ADD, request).andReturn(); String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);