fix(测试跟踪): 用例评审及测试计划关联功能用例,版本字段为空 (#18429)

--bug=1017685 --user=宋昌昌 【测试跟踪】用例评审/测试计划关联功能用例,版本是空 https://www.tapd.cn/55049933/s/1258715

Co-authored-by: song-cc-rock <changchang.song@fit2cloud.com>
This commit is contained in:
MeterSphere Bot 2022-10-12 10:12:06 +08:00 committed by GitHub
parent 0bf8760624
commit 8779823c43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 15 deletions

View File

@ -12,10 +12,7 @@ import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.commons.utils.*;
import io.metersphere.constants.TestCaseCommentType;
import io.metersphere.dto.ProjectConfig;
import io.metersphere.dto.PlanReportCaseDTO;
@ -43,6 +40,7 @@ import io.metersphere.dto.*;
import io.metersphere.request.testcase.TrackCount;
import io.metersphere.request.testreview.SaveCommentRequest;
import io.metersphere.xpack.track.dto.IssuesDao;
import io.metersphere.xpack.version.service.ProjectVersionService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
@ -117,9 +115,14 @@ public class TestPlanTestCaseService {
queryMemberRequest.setProjectId(request.getProjectId());
Map<String, String> userMap = baseUserService.getProjectMemberList(queryMemberRequest)
.stream().collect(Collectors.toMap(User::getId, User::getName));
List<String> versionIds = list.stream().map(TestPlanCaseDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
list.forEach(item -> {
item.setExecutorName(userMap.get(item.getExecutor()));
item.setMaintainerName(userMap.get(item.getMaintainer()));
item.setVersionName(projectVersionMap.get(item.getVersionId()));
});
}
return list;

View File

@ -7,6 +7,7 @@ import io.metersphere.base.mapper.TestCaseReviewTestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewUsersMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.log.vo.DetailColumn;
@ -20,6 +21,7 @@ import io.metersphere.request.testplancase.TestReviewCaseBatchRequest;
import io.metersphere.request.testreview.DeleteRelevanceRequest;
import io.metersphere.request.testreview.QueryCaseReviewRequest;
import io.metersphere.request.testreview.TestCaseReviewTestCaseEditRequest;
import io.metersphere.xpack.version.service.ProjectVersionService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -71,11 +73,16 @@ public class TestReviewTestCaseService {
queryMemberRequest.setWorkspaceId(SessionUtils.getCurrentProjectId());
Map<String, String> userMap = baseUserService.getMemberList(queryMemberRequest)
.stream().collect(Collectors.toMap(User::getId, User::getName));
List<String> versionIds = list.stream().map(TestReviewCaseDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
list.forEach(item -> {
String reviewId = item.getReviewId();
List<String> userIds = getReviewUserIds(reviewId);
item.setReviewerName(getReviewName(userIds, userMap));
item.setMaintainerName(userMap.get(item.getMaintainer()));
item.setVersionName(projectVersionMap.get(item.getVersionId()));
});
return list;
}

View File

@ -15,18 +15,10 @@ export function getCurrentProject(callback) {
}
export function getVersionFilters(projectId) {
if (hasLicense() && projectId) {
return new Promise((resolve) => {
get('/project/version/get-project-versions/' + projectId)
.then(r => {
let versionFilters = r.data.map(u => {
return {text: u.name, value: u.id};
});
resolve(versionFilters);
});
});
if (projectId) {
return get('/project/version/get-project-versions/' + projectId);
}
return new Promise(() => {});
return {};
}