refactor(测试跟踪): 优化功能用例列表的查询方法
--task=1006818 --user=宋天阳 用例表中执行结果字段查询次数多 https://www.tapd.cn/55049933/s/1129403
This commit is contained in:
parent
1a6dfb752a
commit
23f01dfc91
|
@ -136,6 +136,8 @@ public interface ExtTestCaseMapper {
|
||||||
|
|
||||||
String getLastExecStatusById(String id);
|
String getLastExecStatusById(String id);
|
||||||
|
|
||||||
|
List<TestCaseDTO> getLastExecStatusByIdList(@Param("ids") List<String> idList);
|
||||||
|
|
||||||
int countByWorkSpaceId(String workSpaceId);
|
int countByWorkSpaceId(String workSpaceId);
|
||||||
|
|
||||||
long trashCount(@Param("projectId") String projectId);
|
long trashCount(@Param("projectId") String projectId);
|
||||||
|
|
|
@ -939,6 +939,15 @@
|
||||||
ORDER BY update_time DESC limit 1;
|
ORDER BY update_time DESC limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getLastExecStatusByIdList" resultType="io.metersphere.track.dto.TestCaseDTO">
|
||||||
|
SELECT `status`
|
||||||
|
FROM test_plan_test_case
|
||||||
|
WHERE case_id IN
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="countByWorkSpaceId" resultType="java.lang.Integer">
|
<select id="countByWorkSpaceId" resultType="java.lang.Integer">
|
||||||
select count(distinct ref_id)
|
select count(distinct ref_id)
|
||||||
from test_case
|
from test_case
|
||||||
|
|
|
@ -350,6 +350,7 @@ public class TestCaseService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断azure devops用例关联的需求是否发生变更,若发生变更,则重新建立需求与缺陷的关联关系
|
* 判断azure devops用例关联的需求是否发生变更,若发生变更,则重新建立需求与缺陷的关联关系
|
||||||
|
*
|
||||||
* @param testCase
|
* @param testCase
|
||||||
*/
|
*/
|
||||||
private void updateThirdPartyIssuesLink(EditTestCaseRequest testCase) {
|
private void updateThirdPartyIssuesLink(EditTestCaseRequest testCase) {
|
||||||
|
@ -609,7 +610,7 @@ public class TestCaseService {
|
||||||
buildUserInfo(list);
|
buildUserInfo(list);
|
||||||
if (StringUtils.isNotBlank(request.getProjectId())) {
|
if (StringUtils.isNotBlank(request.getProjectId())) {
|
||||||
buildProjectInfo(request.getProjectId(), list);
|
buildProjectInfo(request.getProjectId(), list);
|
||||||
}else{
|
} else {
|
||||||
buildProjectInfoWidthoutProject(list);
|
buildProjectInfoWidthoutProject(list);
|
||||||
}
|
}
|
||||||
list = this.parseStatus(list);
|
list = this.parseStatus(list);
|
||||||
|
@ -648,8 +649,19 @@ public class TestCaseService {
|
||||||
|
|
||||||
private List<TestCaseDTO> parseStatus(List<TestCaseDTO> returnList) {
|
private List<TestCaseDTO> parseStatus(List<TestCaseDTO> returnList) {
|
||||||
TestCaseExcelData excelData = new TestCaseExcelDataFactory().getTestCaseExcelDataLocal();
|
TestCaseExcelData excelData = new TestCaseExcelDataFactory().getTestCaseExcelDataLocal();
|
||||||
|
List<String> testCaseIdList = new ArrayList<>();
|
||||||
|
returnList.forEach(item -> {
|
||||||
|
testCaseIdList.add(item.getId());
|
||||||
|
});
|
||||||
|
|
||||||
|
List<TestCaseDTO> testCaseDTOList = extTestCaseMapper.getLastExecStatusByIdList(testCaseIdList);
|
||||||
|
Map<String, String> testCaseStatusMap = new HashMap<>();
|
||||||
|
testCaseDTOList.forEach(item -> {
|
||||||
|
testCaseStatusMap.put(item.getId(), item.getStatus());
|
||||||
|
});
|
||||||
|
|
||||||
for (TestCaseDTO data : returnList) {
|
for (TestCaseDTO data : returnList) {
|
||||||
String lastStatus = extTestCaseMapper.getLastExecStatusById(data.getId());
|
String lastStatus = testCaseStatusMap.get(data.getId());
|
||||||
if (StringUtils.isNotEmpty(lastStatus)) {
|
if (StringUtils.isNotEmpty(lastStatus)) {
|
||||||
data.setLastExecuteResult(lastStatus);
|
data.setLastExecuteResult(lastStatus);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue