refactor(功能用例): 脑图查询不优先查用例等级

This commit is contained in:
guoyuqi 2024-06-14 16:17:07 +08:00 committed by Craftsman
parent a65ad3a598
commit b5acc24a3c
3 changed files with 37 additions and 9 deletions

View File

@ -2,7 +2,11 @@ package io.metersphere.functional.mapper;
import io.metersphere.dto.TestCaseProviderDTO; import io.metersphere.dto.TestCaseProviderDTO;
import io.metersphere.functional.domain.FunctionalCase; import io.metersphere.functional.domain.FunctionalCase;
import io.metersphere.functional.dto.*; import io.metersphere.functional.domain.FunctionalCaseCustomField;
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
import io.metersphere.functional.dto.FunctionalCaseMindDTO;
import io.metersphere.functional.dto.FunctionalCasePageDTO;
import io.metersphere.functional.dto.FunctionalCaseVersionDTO;
import io.metersphere.functional.request.*; import io.metersphere.functional.request.*;
import io.metersphere.project.dto.ModuleCountDTO; import io.metersphere.project.dto.ModuleCountDTO;
import io.metersphere.request.AssociateOtherCaseRequest; import io.metersphere.request.AssociateOtherCaseRequest;
@ -83,6 +87,9 @@ public interface ExtFunctionalCaseMapper {
*/ */
List<FunctionalCaseMindDTO> getMinderCaseList(@Param("request") FunctionalCaseMindRequest request, @Param("deleted") boolean deleted); List<FunctionalCaseMindDTO> getMinderCaseList(@Param("request") FunctionalCaseMindRequest request, @Param("deleted") boolean deleted);
List<FunctionalCaseCustomField> getCaseCustomFieldList(@Param("request") FunctionalCaseMindRequest request, @Param("deleted") boolean deleted);
/** /**
* 根据模块ID获取用例评审脑图展示数据 * 根据模块ID获取用例评审脑图展示数据
*/ */

View File

@ -793,11 +793,25 @@
<select id="getMinderCaseList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO"> <select id="getMinderCaseList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
SELECT SELECT
fc.id, fc.name, fc.project_id, fc.module_id, fc.template_id, fc.review_status, fc.pos, fc.case_edit_type, fc.id, fc.name, fc.project_id, fc.module_id, fc.template_id, fc.review_status, fc.pos, fc.case_edit_type,
fcb.steps, fcb.text_description, fcb.expected_result, fcb.prerequisite, fcb.description, fccf.value as priority fcb.steps, fcb.text_description, fcb.expected_result, fcb.prerequisite, fcb.description
FROM FROM
functional_case fc functional_case fc
LEFT JOIN functional_case_blob fcb ON fcb.id = fc.id LEFT JOIN functional_case_blob fcb ON fcb.id = fc.id
LEFT JOIN functional_case_custom_field fccf ON fccf.case_id = fc.id WHERE
fc.deleted = false
AND
fc.project_Id = #{request.projectId}
AND
fc.module_id = #{request.moduleId}
order by fc.pos
</select>
<select id="getCaseCustomFieldList" resultType="io.metersphere.functional.domain.FunctionalCaseCustomField">
SELECT
fccf.case_id, fccf.field_id, fccf.value
FROM
functional_case_custom_field fccf
LEFT JOIN functional_case fc ON fccf.case_id = fc.id
LEFT JOIN custom_field cf ON cf.id = fccf.field_id LEFT JOIN custom_field cf ON cf.id = fccf.field_id
WHERE WHERE
fc.deleted = false fc.deleted = false
@ -812,6 +826,7 @@
order by fc.pos order by fc.pos
</select> </select>
<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO"> <select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
SELECT SELECT
crfc.id as id, crfc.id as id,

View File

@ -142,13 +142,15 @@ public class FunctionalCaseMinderService {
return new ArrayList<>(); return new ArrayList<>();
} }
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseList(request, deleted); List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseList(request, deleted);
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
List<FunctionalMinderTreeDTO> functionalMinderTreeDTOS = buildAdditionalData(request.getModuleId()); List<FunctionalMinderTreeDTO> functionalMinderTreeDTOS = buildAdditionalData(request.getModuleId());
if (CollectionUtils.isNotEmpty(functionalMinderTreeDTOS)) { if (CollectionUtils.isNotEmpty(functionalMinderTreeDTOS)) {
list.addAll(functionalMinderTreeDTOS); list.addAll(functionalMinderTreeDTOS);
} }
//构造父子级数据 //构造父子级数据
buildList(functionalCaseMindDTOList, list); buildList(functionalCaseMindDTOList, list, priorityMap);
return list; return list;
} }
@ -175,7 +177,7 @@ public class FunctionalCaseMinderService {
return list; return list;
} }
private void buildList(List<FunctionalCaseMindDTO> functionalCaseMindDTOList, List<FunctionalMinderTreeDTO> list) { private void buildList(List<FunctionalCaseMindDTO> functionalCaseMindDTOList, List<FunctionalMinderTreeDTO> list, Map<String, String> priorityMap) {
//构造父子级数据 //构造父子级数据
for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) { for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) {
FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO(); FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO();
@ -183,7 +185,7 @@ public class FunctionalCaseMinderService {
rootData.setId(functionalCaseMindDTO.getId()); rootData.setId(functionalCaseMindDTO.getId());
rootData.setPos(functionalCaseMindDTO.getPos()); rootData.setPos(functionalCaseMindDTO.getPos());
rootData.setText(functionalCaseMindDTO.getName()); rootData.setText(functionalCaseMindDTO.getName());
rootData.setPriority(StringUtils.isNotBlank(functionalCaseMindDTO.getPriority()) ? Integer.parseInt(functionalCaseMindDTO.getPriority().substring(1))+1 : 1); rootData.setPriority(StringUtils.isNotBlank(priorityMap.get(functionalCaseMindDTO.getId())) ? Integer.parseInt(priorityMap.get(functionalCaseMindDTO.getId()).substring(1))+1 : 1);
rootData.setStatus(functionalCaseMindDTO.getReviewStatus()); rootData.setStatus(functionalCaseMindDTO.getReviewStatus());
rootData.setResource(List.of(Translator.get("minder_extra_node.case"))); rootData.setResource(List.of(Translator.get("minder_extra_node.case")));
List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO); List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO);
@ -1064,8 +1066,10 @@ public class FunctionalCaseMinderService {
List<FunctionalMinderTreeDTO> list = new ArrayList<>(); List<FunctionalMinderTreeDTO> list = new ArrayList<>();
//查出当前模块下的所有用例 //查出当前模块下的所有用例
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseReviewList(request, deleted, userId, viewStatusUserId); List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseReviewList(request, deleted, userId, viewStatusUserId);
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
//构造父子级数据 //构造父子级数据
buildList(functionalCaseMindDTOList, list); buildList(functionalCaseMindDTOList, list, priorityMap);
return list; return list;
} }
@ -1074,8 +1078,10 @@ public class FunctionalCaseMinderService {
List<FunctionalMinderTreeDTO> list = new ArrayList<>(); List<FunctionalMinderTreeDTO> list = new ArrayList<>();
//查出当前模块下的所有用例 //查出当前模块下的所有用例
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderTestPlanList(request, deleted); List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderTestPlanList(request, deleted);
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
//构造父子级数据 //构造父子级数据
buildList(functionalCaseMindDTOList, list); buildList(functionalCaseMindDTOList, list, priorityMap);
return list; return list;
} }