diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index b6901c0b3b..c6b9fb5578 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -48,6 +48,7 @@ import io.metersphere.xpack.track.dto.EditTestCaseRequest; import io.metersphere.xpack.track.dto.IssuesDao; import io.metersphere.xpack.track.dto.request.IssuesRequest; import io.metersphere.xpack.track.issue.IssuesPlatform; +import io.metersphere.xpack.version.service.ProjectVersionService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.collections4.ListUtils; @@ -75,6 +76,8 @@ import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import static io.metersphere.service.ServiceUtils.buildVersionInfo; + @Service @Transactional(rollbackFor = Exception.class) public class TestCaseService { @@ -795,9 +798,9 @@ public class TestCaseService { request.setProjectId(null); ServiceUtils.setBaseQueryRequestCustomMultipleFields(request); List returnList = extTestCaseMapper.publicList(request); - ServiceUtils.buildVersionInfo(returnList); ServiceUtils.buildProjectInfo(returnList); buildUserInfo(returnList); + buildVersionInfo(returnList); buildPublicCustomField(request, returnList); return returnList; } @@ -2838,6 +2841,16 @@ public class TestCaseService { } } + public void buildVersionInfo(List testCases) { + List versionIds = testCases.stream().map(TestCaseDTO::getVersionId).collect(Collectors.toList()); + ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); + Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() + .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); + testCases.forEach(testCase -> { + testCase.setVersionName(projectVersionMap.get(testCase.getVersionId())); + }); + } + public int getRelationshipCount(String id) { return relationshipEdgeService.getRelationshipCount(id, extTestCaseMapper::countByIds); }