From fbab9072d449ed78dc1fddacead7fe019a762d25 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Sat, 15 Jan 2022 18:03:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=85=B3=E7=B3=BB=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=8E=92=E9=99=A4=E5=90=8C=E4=B8=80=E4=B8=AA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E4=B8=8D=E5=90=8C=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009609 --user=刘瑞斌 功能用例、接口定义添加前后置依赖时,会将自身列出来 https://www.tapd.cn/55049933/s/1092532 --- .../api/service/ApiDefinitionService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index fd45cc1711..a1adac47b9 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -46,7 +46,10 @@ import io.metersphere.log.vo.StatusReference; import io.metersphere.log.vo.api.DefinitionReference; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; -import io.metersphere.service.*; +import io.metersphere.service.FileService; +import io.metersphere.service.QuotaService; +import io.metersphere.service.RelationshipEdgeService; +import io.metersphere.service.ScheduleService; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.service.TestPlanService; @@ -1768,8 +1771,15 @@ public class ApiDefinitionService { public Pager> getRelationshipRelateList(ApiDefinitionRequest request, int goPage, @PathVariable int pageSize) { request = this.initRequest(request, true, true); + // 排除同一个api的不同版本 + ApiDefinitionWithBLOBs currentApi = apiDefinitionMapper.selectByPrimaryKey(request.getId()); + ApiDefinitionExample example = new ApiDefinitionExample(); + example.createCriteria().andRefIdEqualTo(currentApi.getRefId()); + List apiDefinitions = apiDefinitionMapper.selectByExample(example); + List sameApiIds = apiDefinitions.stream().map(ApiDefinition::getId).collect(Collectors.toList()); List relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); - request.setNotInIds(relationshipIds); + sameApiIds.addAll(relationshipIds); + request.setNotInIds(sameApiIds); request.setId(null); // 去掉id的查询条件 Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, extApiDefinitionMapper.list(request));