fix(测试跟踪): 功能用例,回收站,缺陷管理列表自定义多选字段筛选及高级搜索问题
--bug=1016257 --user=宋昌昌 【测试跟踪】功能用例,回收站列表,高级搜索,“多选下拉列表”不属于,筛选无效 https://www.tapd.cn/55049933/s/1234070
This commit is contained in:
parent
b084094302
commit
58359cb409
|
@ -261,10 +261,10 @@
|
|||
and issues.id in (
|
||||
select resource_id from custom_field_issues
|
||||
where concat('custom_multiple-',field_id) = #{key}
|
||||
and JSON_CONTAINS(value,
|
||||
<foreach collection="values" item="value" separator="" open="" close="">
|
||||
#{value}
|
||||
</foreach>)
|
||||
and
|
||||
<foreach collection="values" item="value" separator="or" open="(" close=")">
|
||||
JSON_CONTAINS(value, #{value})
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
|
@ -309,18 +309,11 @@
|
|||
</if>
|
||||
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
||||
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
|
||||
and issues.id in (
|
||||
and issues.id ${custom.operator} (
|
||||
select resource_id from custom_field_issues where field_id = #{custom.id}
|
||||
<choose>
|
||||
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
||||
<choose>
|
||||
<when test="custom.operator == 'in'">
|
||||
and JSON_CONTAINS(`value`, #{custom.value})
|
||||
</when>
|
||||
<otherwise>
|
||||
and NOT JSON_CONTAINS(`value`, #{custom.value})
|
||||
</otherwise>
|
||||
</choose>
|
||||
and ${custom.value}
|
||||
</when>
|
||||
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
||||
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
||||
|
@ -341,7 +334,7 @@
|
|||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
)
|
||||
)
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
|
|
@ -108,38 +108,31 @@
|
|||
</if>
|
||||
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
||||
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
|
||||
and test_case.id in (
|
||||
select resource_id from custom_field_test_case where field_id = #{custom.id}
|
||||
<choose>
|
||||
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
||||
<choose>
|
||||
<when test="custom.operator == 'in'">
|
||||
and JSON_CONTAINS(`value`, #{custom.value})
|
||||
</when>
|
||||
<otherwise>
|
||||
and NOT JSON_CONTAINS(`value`, #{custom.value})
|
||||
</otherwise>
|
||||
</choose>
|
||||
</when>
|
||||
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
||||
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="custom.type == 'richText' or custom.type == 'textarea'">
|
||||
and text_value
|
||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</when>
|
||||
<otherwise>
|
||||
and trim(both '"' from value)
|
||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
and test_case.id ${custom.operator} (
|
||||
select resource_id from custom_field_test_case where field_id = #{custom.id}
|
||||
<choose>
|
||||
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
||||
and ${custom.value}
|
||||
</when>
|
||||
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
||||
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="custom.type == 'richText' or custom.type == 'textarea'">
|
||||
and text_value
|
||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</when>
|
||||
<otherwise>
|
||||
and trim(both '"' from value)
|
||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||
<property name="object" value="custom"/>
|
||||
</include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
)
|
||||
</foreach>
|
||||
</if>
|
||||
|
@ -605,10 +598,10 @@
|
|||
<when test="key.startsWith('custom_multiple')">
|
||||
and test_case.id in (
|
||||
select resource_id from custom_field_test_case where concat('custom_multiple-',field_id) = #{key}
|
||||
and JSON_CONTAINS(value,
|
||||
<foreach collection="values" item="value" separator="" open="" close="">
|
||||
#{value}
|
||||
</foreach>)
|
||||
and
|
||||
<foreach collection="values" item="value" separator="or" open="(" close=")">
|
||||
JSON_CONTAINS(value, #{value})
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
<when test="key=='create_user'">
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.ProjectVersion;
|
||||
import io.metersphere.base.domain.User;
|
||||
import io.metersphere.base.domain.Workspace;
|
||||
import io.metersphere.commons.constants.CustomFieldType;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.controller.request.BaseQueryRequest;
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
|
@ -13,6 +15,8 @@ import io.metersphere.service.ProjectService;
|
|||
import io.metersphere.service.ProjectVersionService;
|
||||
import io.metersphere.service.UserService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
@ -419,4 +423,31 @@ public class ServiceUtils {
|
|||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void setBaseQueryRequestCustomMultipleFields(BaseQueryRequest request) {
|
||||
// filter中自定义多选字段
|
||||
if (MapUtils.isNotEmpty(request.getFilters())) {
|
||||
request.getFilters().entrySet().forEach(entry -> {
|
||||
if (entry.getKey().startsWith("custom_multiple") && CollectionUtils.isNotEmpty(entry.getValue())) {
|
||||
List<String> customValues = JSONArray.parseArray(entry.getValue().get(0), String.class);
|
||||
List<String> jsonValues = customValues.stream().map(item -> "[\"".concat(item).concat("\"]")).collect(Collectors.toList());
|
||||
entry.setValue(jsonValues);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 高级搜索中自定义多选字段
|
||||
if (MapUtils.isNotEmpty(request.getCombine()) && ObjectUtils.isNotEmpty((request.getCombine().get("customs")))) {
|
||||
List<Map<String, Object>> customs = (List<Map<String, Object>>) request.getCombine().get("customs");
|
||||
customs.forEach(custom -> {
|
||||
if (StringUtils.equalsAny(custom.get("type").toString(), CustomFieldType.MULTIPLE_MEMBER.getValue(),
|
||||
CustomFieldType.CHECKBOX.getValue(), CustomFieldType.MULTIPLE_SELECT.getValue())
|
||||
&& StringUtils.isNotEmpty(custom.get("value").toString())) {
|
||||
List<String> customValues = JSONArray.parseArray(custom.get("value").toString(), String.class);
|
||||
List<String> jsonValues = customValues.stream().map(item -> "JSON_CONTAINS(`value`, '[\"".concat(item).concat("\"]')")).collect(Collectors.toList());
|
||||
custom.put("value", "(".concat(StringUtils.join(jsonValues, " OR ")).concat(")"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,6 +397,7 @@ public class IssuesService {
|
|||
order.setName("value");
|
||||
}
|
||||
});
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<IssuesDao> issues = extIssuesMapper.getIssues(request);
|
||||
|
||||
Map<String, Set<String>> caseSetMap = getCaseSetMap(issues);
|
||||
|
|
|
@ -15,6 +15,7 @@ import io.metersphere.commons.constants.TestCaseConstants;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.dto.NodeNumDTO;
|
||||
import io.metersphere.exception.ExcelException;
|
||||
|
@ -250,6 +251,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
request.setProjectId(projectId);
|
||||
request.setUserId(SessionUtils.getUserId());
|
||||
request.setNodeIds(null);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getCountNodes(request);
|
||||
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
|
||||
return getNodeTrees(testCaseNodes, getCountMap(countMNodes));
|
||||
|
@ -275,6 +277,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
request.setWorkspaceId(workspaceId);
|
||||
request.setProjectId(null);
|
||||
request.setNodeIds(null);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getWorkspaceCountNodes(request);
|
||||
return getNodeTreeWithPruningTree(countModules);
|
||||
}
|
||||
|
@ -285,6 +288,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
extTestCaseMapper.updateNoModuleTrashNodeToDefault(projectId, defaultNode.getId(), defaultNode.getName());
|
||||
request.setProjectId(projectId);
|
||||
request.setNodeIds(null);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getCountNodes(request);
|
||||
countModules.forEach(item -> item.setProjectId(projectId));
|
||||
return getNodeTreeWithPruningTree(countModules);
|
||||
|
|
|
@ -725,6 +725,7 @@ public class TestCaseService {
|
|||
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) {
|
||||
this.initRequest(request, true);
|
||||
setDefaultOrder(request);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
if (request.getFilters() != null && !request.getFilters().containsKey("status")) {
|
||||
request.getFilters().put("status", new ArrayList<>(0));
|
||||
}
|
||||
|
@ -782,10 +783,12 @@ public class TestCaseService {
|
|||
MSException.throwException("workspaceId could not be null!");
|
||||
}
|
||||
request.setProjectId(null);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<TestCaseDTO> returnList = extTestCaseMapper.publicList(request);
|
||||
ServiceUtils.buildVersionInfo(returnList);
|
||||
ServiceUtils.buildProjectInfo(returnList);
|
||||
buildUserInfo(returnList);
|
||||
buildCustomField(returnList);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue