From 2333ca5c274fdd53990fdac0714697e774c8e502 Mon Sep 17 00:00:00 2001 From: MeterSphere Bot <78466014+metersphere-bot@users.noreply.github.com> Date: Fri, 14 Oct 2022 23:46:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=B5=8B=E8=AF=95=E6=A8=A1=E5=9D=97=E6=A0=91?= =?UTF-8?q?=E5=8F=8A=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1017975 --user=宋昌昌 【测试跟踪】测试用例-关联测试-选择其他项目-左侧模块统计数是0 https://www.tapd.cn/55049933/s/1262038 Co-authored-by: song-cc-rock --- .../service/definition/ApiTestCaseService.java | 17 +++++++++++++++-- .../case/components/TestCaseApiRelate.vue | 4 ++-- .../case/components/TestCaseScenarioRelate.vue | 1 + .../view/comonents/api/module/ApiModule.vue | 3 +++ .../functional/FunctionalTestCaseList.vue | 2 +- .../comonents/load/TestPlanLoadCaseList.vue | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index c87c188686..6992eed434 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -37,6 +37,7 @@ import io.metersphere.service.plan.TestPlanApiCaseService; import io.metersphere.service.scenario.ApiScenarioReferenceIdService; import io.metersphere.xpack.api.service.ApiCaseBatchSyncService; import io.metersphere.xpack.api.service.ApiTestCaseSyncService; +import io.metersphere.xpack.version.service.ProjectVersionService; import org.apache.commons.beanutils.BeanComparator; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.comparators.FixedOrderComparator; @@ -1157,13 +1158,25 @@ public class ApiTestCaseService { public List getRelevanceApiList(ApiTestCaseRequest request) { List apiTestCaseDTOS = extApiTestCaseMapper.relevanceApiList(request); - ServiceUtils.buildVersionInfo(apiTestCaseDTOS); + List versionIds = apiTestCaseDTOS.stream().map(ApiTestCaseDTO::getVersionId).collect(Collectors.toList()); + ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); + Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() + .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); + apiTestCaseDTOS.forEach(apiTestCaseDTO -> { + apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId())); + }); return apiTestCaseDTOS; } public List getRelevanceScenarioList(ApiScenarioRequest request) { List apiScenarioDTOS = extApiScenarioMapper.relevanceScenarioList(request); - ServiceUtils.buildVersionInfo(apiScenarioDTOS); + List versionIds = apiScenarioDTOS.stream().map(ApiScenarioDTO::getVersionId).collect(Collectors.toList()); + ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); + Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() + .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); + apiScenarioDTOS.forEach(apiTestCaseDTO -> { + apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId())); + }); return apiScenarioDTOS; } diff --git a/test-track/frontend/src/business/case/components/TestCaseApiRelate.vue b/test-track/frontend/src/business/case/components/TestCaseApiRelate.vue index a07326de7b..a247b4110d 100644 --- a/test-track/frontend/src/business/case/components/TestCaseApiRelate.vue +++ b/test-track/frontend/src/business/case/components/TestCaseApiRelate.vue @@ -7,6 +7,7 @@