fix(接口测试): 分享永久有效排序问题

--bug=1048322 --user=宋昌昌 【接口测试】定义-分享-分享列表-截止时间排序-永久有效应该是最大的值 https://www.tapd.cn/55049933/s/1601843
This commit is contained in:
song-cc-rock 2024-10-30 11:31:29 +08:00 committed by Craftsman
parent c0133cc8f0
commit 277b406aff
2 changed files with 7 additions and 1 deletions

View File

@ -88,6 +88,7 @@ public class ApiDocShareService {
docShare.setCreateTime(System.currentTimeMillis()); docShare.setCreateTime(System.currentTimeMillis());
docShare.setUpdateUser(currentUser); docShare.setUpdateUser(currentUser);
docShare.setUpdateTime(System.currentTimeMillis()); docShare.setUpdateTime(System.currentTimeMillis());
docShare.setInvalidTime(request.getInvalidTime() == 0 ? Long.MAX_VALUE : request.getInvalidTime());
apiDocShareMapper.insert(docShare); apiDocShareMapper.insert(docShare);
return docShare; return docShare;
} }
@ -104,6 +105,7 @@ public class ApiDocShareService {
BeanUtils.copyBean(docShare, request); BeanUtils.copyBean(docShare, request);
docShare.setUpdateUser(currentUser); docShare.setUpdateUser(currentUser);
docShare.setUpdateTime(System.currentTimeMillis()); docShare.setUpdateTime(System.currentTimeMillis());
docShare.setInvalidTime(request.getInvalidTime() == 0 ? Long.MAX_VALUE : request.getInvalidTime());
apiDocShareMapper.updateByPrimaryKeySelective(docShare); apiDocShareMapper.updateByPrimaryKeySelective(docShare);
return docShare; return docShare;
} }
@ -138,7 +140,7 @@ public class ApiDocShareService {
public ApiDocShareDetail detail(String id) { public ApiDocShareDetail detail(String id) {
ApiDocShare docShare = checkExit(id); ApiDocShare docShare = checkExit(id);
ApiDocShareDetail detail = ApiDocShareDetail.builder().allowExport(docShare.getAllowExport()).isPrivate(docShare.getIsPrivate()).build(); 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); detail.setInvalid(false);
} else { } else {
detail.setInvalid(docShare.getInvalidTime() < System.currentTimeMillis()); detail.setInvalid(docShare.getInvalidTime() < System.currentTimeMillis());
@ -210,6 +212,9 @@ public class ApiDocShareService {
List<String> distinctUpdateUserIds = docShares.stream().map(ApiDocShareDTO::getUpdateUser).distinct().toList(); List<String> distinctUpdateUserIds = docShares.stream().map(ApiDocShareDTO::getUpdateUser).distinct().toList();
Map<String, String> userMap = userToolService.getUserMapByIds(ListUtils.union(distinctCreateUserIds, distinctUpdateUserIds)); Map<String, String> userMap = userToolService.getUserMapByIds(ListUtils.union(distinctCreateUserIds, distinctUpdateUserIds));
docShares.forEach(docShare -> { 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.setInvalid(docShare.getInvalidTime() != null && docShare.getInvalidTime() != 0 && docShare.getInvalidTime() < System.currentTimeMillis());
docShare.setApiShareNum(countApiShare(docShare)); docShare.setApiShareNum(countApiShare(docShare));
docShare.setCreateUserName(userMap.get(docShare.getCreateUser())); docShare.setCreateUserName(userMap.get(docShare.getCreateUser()));

View File

@ -54,6 +54,7 @@ public class ApiDocShareControllerTests extends BaseTest {
request.setIsPrivate(false); request.setIsPrivate(false);
request.setPassword("123456"); request.setPassword("123456");
request.setAllowExport(false); request.setAllowExport(false);
request.setInvalidTime(0L);
MvcResult mvcResult = this.requestPostWithOk(ADD, request).andReturn(); MvcResult mvcResult = this.requestPostWithOk(ADD, request).andReturn();
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);