diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 9b1ee3a8f9..78355cb18f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -226,14 +226,11 @@ test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num, test_case.other_test_name, test_case.review_status, test_case.tags, test_case.demand_id, test_case.demand_name, test_case.`status`, - test_case.custom_num, test_case.step_model, test_case.create_user,u.name as createName, - test_case.custom_fields, project.name as projectName , test_case.ref_id + test_case.custom_num, test_case.step_model, test_case.create_user, + test_case.custom_fields, test_case.ref_id - from test_case left join user u on test_case.create_user=u.id - left join user deleteUser on test_case.delete_user_id=deleteUser.id - left join project on test_case.project_id = project.id - left join project_version on project.id = project_version.project_id and project_version.id = - test_case.version_id + from test_case + left join project_version on project_version.id = test_case.version_id and project_version.project_id = #{request.project_id} diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 7476dc8feb..9d6a3537d8 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -532,9 +532,11 @@ public class TestCaseService { if (request.getFilters() != null && !request.getFilters().containsKey("status")) { request.getFilters().put("status", new ArrayList<>(0)); } - List returnList = extTestCaseMapper.list(request); - returnList = this.parseStatus(returnList); - return returnList; + List list = extTestCaseMapper.list(request); + buildUserInfo(list); + buildProjectInfo(request.getProjectId(), list); + list = this.parseStatus(list); + return list; } public List publicListTestCase(QueryTestCaseRequest request) { @@ -2332,7 +2334,8 @@ public class TestCaseService { TestCaseExample example = new TestCaseExample(); example.createCriteria().andIdIn(ids).andStatusNotEqualTo("Trash"); List testCaseList = testCaseMapper.selectByExampleWithBLOBs(example); - buildUserInfo(testCaseList); + + Map userNameMap = ServiceUtils.getUserNameMap(testCaseList.stream().map(TestCaseWithBLOBs::getCreateUser).collect(Collectors.toList())); Map verionNameMap = new HashMap<>(); List versionIds = testCaseList.stream().map(TestCase::getVersionId).collect(Collectors.toList()); @@ -2357,7 +2360,7 @@ public class TestCaseService { continue; // 用例可能在回收站 } relationshipEdgeDTO.setTargetName(testCase.getName()); - relationshipEdgeDTO.setCreator(testCase.getCreateUser()); + relationshipEdgeDTO.setCreator(userNameMap.get(testCase.getCreateUser())); relationshipEdgeDTO.setTargetNum(testCase.getNum()); relationshipEdgeDTO.setTargetCustomNum(testCase.getCustomNum()); relationshipEdgeDTO.setStatus(testCase.getStatus()); @@ -2369,7 +2372,14 @@ public class TestCaseService { return new ArrayList<>(); } - public void buildUserInfo(List testCases) { + public void buildProjectInfo(String projectId, List list) { + Project project = projectService.getProjectById(projectId); + list.forEach(item -> { + item.setProjectName(project.getName()); + }); + } + + public void buildUserInfo(List testCases) { List userIds = new ArrayList(); userIds.addAll(testCases.stream().map(TestCase::getCreateUser).collect(Collectors.toList())); userIds.addAll(testCases.stream().map(TestCase::getDeleteUserId).collect(Collectors.toList())); @@ -2377,9 +2387,9 @@ public class TestCaseService { if (!org.apache.commons.collections.CollectionUtils.isEmpty(userIds)) { Map userMap = ServiceUtils.getUserNameMap(userIds); testCases.forEach(caseResult -> { - caseResult.setCreateUser(userMap.get(caseResult.getCreateUser())); + caseResult.setCreateName(userMap.get(caseResult.getCreateUser())); caseResult.setDeleteUserId(userMap.get(caseResult.getDeleteUserId())); - caseResult.setMaintainer(userMap.get(caseResult.getMaintainer())); + caseResult.setMaintainerName(userMap.get(caseResult.getMaintainer())); }); } } diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 2296e5f1f0..d54fad71e9 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -98,15 +98,11 @@ - - + min-width="120"/>