feat(测试计划): 用例列表返回缺陷数

This commit is contained in:
WangXu10 2024-05-20 17:06:00 +08:00 committed by 刘瑞斌
parent 9bb85bad49
commit e51c44db3c
3 changed files with 6 additions and 4 deletions

View File

@ -80,12 +80,13 @@ public interface ExtBugRelateCaseMapper {
*/
long countByCaseId(String caseId);
List<CaseRelateBugDTO> getBugCountByIds(@Param("ids") List<String> ids);
List<CaseRelateBugDTO> getBugCountByIds(@Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
List<BugProviderDTO> getTestPlanAssociateBugs(@Param("request") AssociateBugPageRequest request, @Param("sort") String sort);
/**
* 获取计划关联的缺陷ID集合(去重)
*
* @param planId 计划ID
* @return 缺陷ID集合
*/

View File

@ -272,6 +272,7 @@
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and bug_relation_case.test_plan_id = #{testPlanId}
ORDER BY
bug.pos DESC
</select>

View File

@ -204,7 +204,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
Map<String, List<FunctionalCaseCustomFieldDTO>> collect = functionalCaseService.getCaseCustomFiledMap(ids, projectId);
Set<String> userIds = extractUserIds(functionalCaseLists);
List<String> relateIds = functionalCaseLists.stream().map(TestPlanCasePageResponse::getId).collect(Collectors.toList());
Map<String, List<CaseRelateBugDTO>> bugListMap = getBugData(relateIds);
Map<String, List<CaseRelateBugDTO>> bugListMap = getBugData(relateIds, functionalCaseLists.get(0).getTestPlanId());
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds));
functionalCaseLists.forEach(testPlanCasePageResponse -> {
testPlanCasePageResponse.setCustomFields(collect.get(testPlanCasePageResponse.getCaseId()));
@ -220,8 +220,8 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
}
private Map<String, List<CaseRelateBugDTO>> getBugData(List<String> ids) {
List<CaseRelateBugDTO> bugList = bugRelateCaseMapper.getBugCountByIds(ids);
private Map<String, List<CaseRelateBugDTO>> getBugData(List<String> ids, String testPlanId) {
List<CaseRelateBugDTO> bugList = bugRelateCaseMapper.getBugCountByIds(ids, testPlanId);
return bugList.stream().collect(Collectors.groupingBy(CaseRelateBugDTO::getCaseId));
}