feat(测试跟踪): 高级搜索支持多个标签

--story=1011281 --user=宋昌昌 高级搜索支持多个标签搜索 https://www.tapd.cn/55049933/s/1360408
This commit is contained in:
song-cc-rock 2023-04-07 18:08:38 +08:00
parent 60ed39d2f5
commit d805b50884
6 changed files with 39 additions and 20 deletions

View File

@ -490,6 +490,17 @@ public class ServiceUtils {
}
}
public static void buildCombineTagsToSupportMultiple(BaseQueryRequest request) {
if (request.getCombine() != null && request.getCombine().containsKey("tags")) {
Map<String, Object> tagsMap = (Map<String, Object>) request.getCombine().get("tags");
Object tagVal = tagsMap.get("value");
if (tagVal != null) {
List<String> tagList = Arrays.asList(tagVal.toString().split(StringUtils.SPACE));
tagsMap.put("value", tagList);
}
}
}
private static void buildCustomNumInfo(Map<String, String> customNumMap, Object data) {
Class<?> clazz = data.getClass();
try {

View File

@ -88,18 +88,18 @@
<property name="object" value="${condition}.creator"/>
</include>
</if>
<if test='${condition}.tags != null and ${objectKey}.operator == "not like"'>
and (test_case.tags is null or test_case.tags
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="${condition}.tags"/>
</include>
<if test='${condition}.tags != null and ${objectKey}.value.size() > 0 and ${objectKey}.operator == "not like"'>
and ( test_case.tags is null or
<foreach collection="${objectKey}.value" item="tag" separator="and" open="(" close=")">
test_case.tags not like concat('%', #{tag},'%')
</foreach>
)
</if>
<if test='${condition}.tags != null and ${objectKey}.operator == "like"'>
and test_case.tags
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="${condition}.tags"/>
</include>
<if test='${condition}.tags != null and ${objectKey}.value.size() > 0 and ${objectKey}.operator == "like"'>
and
<foreach collection="${objectKey}.value" item="tag" separator="or" open="(" close=")">
test_case.tags like concat('%', #{tag},'%')
</foreach>
</if>
<if test="${condition}.reviewStatus != null">
and test_case.review_status

View File

@ -113,18 +113,18 @@
<property name="object" value="${condition}.executor"/>
</include>
</if>
<if test='${condition}.tags != null and ${objectKey}.operator == "not like"'>
and (test_case.tags is null or test_case.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
<if test='${condition}.tags != null and ${objectKey}.value.size() > 0 and ${objectKey}.operator == "not like"'>
and ( test_case.tags is null or
<foreach collection="${objectKey}.value" item="tag" separator="and" open="(" close=")">
test_case.tags not like concat('%', #{tag},'%')
</foreach>
)
</if>
<if test='${condition}.tags != null and ${objectKey}.operator == "like"'>
and test_case.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
<if test='${condition}.tags != null and ${objectKey}.value.size() > 0 and ${objectKey}.operator == "like"'>
and
<foreach collection="${objectKey}.value" item="tag" separator="or" open="(" close=")">
test_case.tags like concat('%', #{tag},'%')
</foreach>
</if>
<if test='${condition}.planCaseStatus != null'>
and test_plan_test_case.status

View File

@ -105,6 +105,7 @@ public class TestPlanTestCaseService {
}
public List<TestPlanCaseDTO> list(QueryTestPlanCaseRequest request) {
ServiceUtils.buildCombineTagsToSupportMultiple(request);
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);
Map<String, List<CustomFieldDao>> fieldMap =
customFieldTestCaseService.getMapByResourceIds(list.stream().map(TestPlanCaseDTO::getCaseId).collect(Collectors.toList()));

View File

@ -254,6 +254,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
request.setProjectId(projectId);
request.setUserId(SessionUtils.getUserId());
request.setNodeIds(null);
ServiceUtils.buildCombineTagsToSupportMultiple(request);
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getCountNodes(request);
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
@ -272,6 +273,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
request.setPlanId(planId);
request.setProjectId(null);
request.setNodeIds(null);
ServiceUtils.buildCombineTagsToSupportMultiple(request);
List<TestCaseNodeDTO> countModules = extTestPlanTestCaseMapper.getTestPlanCountNodes(request);
return getNodeTreeWithPruningTree(countModules);
}
@ -366,6 +368,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
public List<TestCaseNodeDTO> getRelatePlanNodes(QueryTestCaseRequest request) {
request.setNodeIds(null);
ServiceUtils.buildCombineTagsToSupportMultiple(request);
if (testPlanService.isAllowedRepeatCase(request.getPlanId())) {
request.setRepeatCase(true);
}
@ -377,6 +380,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
public List<TestCaseNodeDTO> getRelateReviewNodes(QueryTestCaseRequest request) {
request.setNodeIds(null);
ServiceUtils.buildCombineTagsToSupportMultiple(request);
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getTestReviewRelateCountNodes(request);
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(request.getProjectId());
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);

View File

@ -802,6 +802,7 @@ public class TestCaseService {
if (request.getFilters() != null && !request.getFilters().containsKey("status")) {
request.getFilters().put("status", new ArrayList<>(0));
}
ServiceUtils.buildCombineTagsToSupportMultiple(request);
List<TestCaseDTO> list = extTestCaseMapper.list(request);
if (!isSampleInfo) {
buildUserInfo(list);
@ -977,6 +978,7 @@ public class TestCaseService {
}
public List<TestCaseDTO> getTestCaseByNotInPlan(QueryTestCaseRequest request) {
ServiceUtils.buildCombineTagsToSupportMultiple(request);
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
return extTestCaseMapper.getTestCaseByNotInPlan(request);
}
@ -1023,6 +1025,7 @@ public class TestCaseService {
public List<TestCaseDTO> getReviewCase(QueryTestCaseRequest request) {
setDefaultOrder(request);
ServiceUtils.buildCombineTagsToSupportMultiple(request);
request.getOrders().forEach(order -> {
order.setPrefix("test_case");
});