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 (
|
and issues.id in (
|
||||||
select resource_id from custom_field_issues
|
select resource_id from custom_field_issues
|
||||||
where concat('custom_multiple-',field_id) = #{key}
|
where concat('custom_multiple-',field_id) = #{key}
|
||||||
and JSON_CONTAINS(value,
|
and
|
||||||
<foreach collection="values" item="value" separator="" open="" close="">
|
<foreach collection="values" item="value" separator="or" open="(" close=")">
|
||||||
#{value}
|
JSON_CONTAINS(value, #{value})
|
||||||
</foreach>)
|
</foreach>
|
||||||
)
|
)
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
|
@ -309,18 +309,11 @@
|
||||||
</if>
|
</if>
|
||||||
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
||||||
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
|
<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}
|
select resource_id from custom_field_issues where field_id = #{custom.id}
|
||||||
<choose>
|
<choose>
|
||||||
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
||||||
<choose>
|
and ${custom.value}
|
||||||
<when test="custom.operator == 'in'">
|
|
||||||
and JSON_CONTAINS(`value`, #{custom.value})
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
and NOT JSON_CONTAINS(`value`, #{custom.value})
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</when>
|
</when>
|
||||||
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
||||||
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
||||||
|
@ -341,7 +334,7 @@
|
||||||
</include>
|
</include>
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
|
@ -108,38 +108,31 @@
|
||||||
</if>
|
</if>
|
||||||
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
|
||||||
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
|
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
|
||||||
and test_case.id in (
|
and test_case.id ${custom.operator} (
|
||||||
select resource_id from custom_field_test_case where field_id = #{custom.id}
|
select resource_id from custom_field_test_case where field_id = #{custom.id}
|
||||||
<choose>
|
<choose>
|
||||||
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
|
||||||
<choose>
|
and ${custom.value}
|
||||||
<when test="custom.operator == 'in'">
|
</when>
|
||||||
and JSON_CONTAINS(`value`, #{custom.value})
|
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
||||||
</when>
|
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
||||||
<otherwise>
|
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||||
and NOT JSON_CONTAINS(`value`, #{custom.value})
|
<property name="object" value="custom"/>
|
||||||
</otherwise>
|
</include>
|
||||||
</choose>
|
</when>
|
||||||
</when>
|
<when test="custom.type == 'richText' or custom.type == 'textarea'">
|
||||||
<when test="custom.type == 'date' or custom.type == 'datetime'">
|
and text_value
|
||||||
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
|
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
<property name="object" value="custom"/>
|
||||||
<property name="object" value="custom"/>
|
</include>
|
||||||
</include>
|
</when>
|
||||||
</when>
|
<otherwise>
|
||||||
<when test="custom.type == 'richText' or custom.type == 'textarea'">
|
and trim(both '"' from value)
|
||||||
and text_value
|
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
||||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
<property name="object" value="custom"/>
|
||||||
<property name="object" value="custom"/>
|
</include>
|
||||||
</include>
|
</otherwise>
|
||||||
</when>
|
</choose>
|
||||||
<otherwise>
|
|
||||||
and trim(both '"' from value)
|
|
||||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
|
|
||||||
<property name="object" value="custom"/>
|
|
||||||
</include>
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
@ -605,10 +598,10 @@
|
||||||
<when test="key.startsWith('custom_multiple')">
|
<when test="key.startsWith('custom_multiple')">
|
||||||
and test_case.id in (
|
and test_case.id in (
|
||||||
select resource_id from custom_field_test_case where concat('custom_multiple-',field_id) = #{key}
|
select resource_id from custom_field_test_case where concat('custom_multiple-',field_id) = #{key}
|
||||||
and JSON_CONTAINS(value,
|
and
|
||||||
<foreach collection="values" item="value" separator="" open="" close="">
|
<foreach collection="values" item="value" separator="or" open="(" close=")">
|
||||||
#{value}
|
JSON_CONTAINS(value, #{value})
|
||||||
</foreach>)
|
</foreach>
|
||||||
)
|
)
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='create_user'">
|
<when test="key=='create_user'">
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package io.metersphere.commons.utils;
|
package io.metersphere.commons.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import io.metersphere.base.domain.Project;
|
import io.metersphere.base.domain.Project;
|
||||||
import io.metersphere.base.domain.ProjectVersion;
|
import io.metersphere.base.domain.ProjectVersion;
|
||||||
import io.metersphere.base.domain.User;
|
import io.metersphere.base.domain.User;
|
||||||
import io.metersphere.base.domain.Workspace;
|
import io.metersphere.base.domain.Workspace;
|
||||||
|
import io.metersphere.commons.constants.CustomFieldType;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.controller.request.BaseQueryRequest;
|
import io.metersphere.controller.request.BaseQueryRequest;
|
||||||
import io.metersphere.controller.request.OrderRequest;
|
import io.metersphere.controller.request.OrderRequest;
|
||||||
|
@ -13,6 +15,8 @@ import io.metersphere.service.ProjectService;
|
||||||
import io.metersphere.service.ProjectVersionService;
|
import io.metersphere.service.ProjectVersionService;
|
||||||
import io.metersphere.service.UserService;
|
import io.metersphere.service.UserService;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
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.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
@ -419,4 +423,31 @@ public class ServiceUtils {
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.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");
|
order.setName("value");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
List<IssuesDao> issues = extIssuesMapper.getIssues(request);
|
List<IssuesDao> issues = extIssuesMapper.getIssues(request);
|
||||||
|
|
||||||
Map<String, Set<String>> caseSetMap = getCaseSetMap(issues);
|
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.exception.MSException;
|
||||||
import io.metersphere.commons.utils.BeanUtils;
|
import io.metersphere.commons.utils.BeanUtils;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.commons.utils.ServiceUtils;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.NodeNumDTO;
|
import io.metersphere.dto.NodeNumDTO;
|
||||||
import io.metersphere.exception.ExcelException;
|
import io.metersphere.exception.ExcelException;
|
||||||
|
@ -250,6 +251,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
request.setProjectId(projectId);
|
request.setProjectId(projectId);
|
||||||
request.setUserId(SessionUtils.getUserId());
|
request.setUserId(SessionUtils.getUserId());
|
||||||
request.setNodeIds(null);
|
request.setNodeIds(null);
|
||||||
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getCountNodes(request);
|
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getCountNodes(request);
|
||||||
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
|
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
|
||||||
return getNodeTrees(testCaseNodes, getCountMap(countMNodes));
|
return getNodeTrees(testCaseNodes, getCountMap(countMNodes));
|
||||||
|
@ -275,6 +277,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
request.setWorkspaceId(workspaceId);
|
request.setWorkspaceId(workspaceId);
|
||||||
request.setProjectId(null);
|
request.setProjectId(null);
|
||||||
request.setNodeIds(null);
|
request.setNodeIds(null);
|
||||||
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getWorkspaceCountNodes(request);
|
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getWorkspaceCountNodes(request);
|
||||||
return getNodeTreeWithPruningTree(countModules);
|
return getNodeTreeWithPruningTree(countModules);
|
||||||
}
|
}
|
||||||
|
@ -285,6 +288,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
||||||
extTestCaseMapper.updateNoModuleTrashNodeToDefault(projectId, defaultNode.getId(), defaultNode.getName());
|
extTestCaseMapper.updateNoModuleTrashNodeToDefault(projectId, defaultNode.getId(), defaultNode.getName());
|
||||||
request.setProjectId(projectId);
|
request.setProjectId(projectId);
|
||||||
request.setNodeIds(null);
|
request.setNodeIds(null);
|
||||||
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getCountNodes(request);
|
List<TestCaseNodeDTO> countModules = extTestCaseMapper.getCountNodes(request);
|
||||||
countModules.forEach(item -> item.setProjectId(projectId));
|
countModules.forEach(item -> item.setProjectId(projectId));
|
||||||
return getNodeTreeWithPruningTree(countModules);
|
return getNodeTreeWithPruningTree(countModules);
|
||||||
|
|
|
@ -725,6 +725,7 @@ public class TestCaseService {
|
||||||
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) {
|
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) {
|
||||||
this.initRequest(request, true);
|
this.initRequest(request, true);
|
||||||
setDefaultOrder(request);
|
setDefaultOrder(request);
|
||||||
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
if (request.getFilters() != null && !request.getFilters().containsKey("status")) {
|
if (request.getFilters() != null && !request.getFilters().containsKey("status")) {
|
||||||
request.getFilters().put("status", new ArrayList<>(0));
|
request.getFilters().put("status", new ArrayList<>(0));
|
||||||
}
|
}
|
||||||
|
@ -782,10 +783,12 @@ public class TestCaseService {
|
||||||
MSException.throwException("workspaceId could not be null!");
|
MSException.throwException("workspaceId could not be null!");
|
||||||
}
|
}
|
||||||
request.setProjectId(null);
|
request.setProjectId(null);
|
||||||
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
List<TestCaseDTO> returnList = extTestCaseMapper.publicList(request);
|
List<TestCaseDTO> returnList = extTestCaseMapper.publicList(request);
|
||||||
ServiceUtils.buildVersionInfo(returnList);
|
ServiceUtils.buildVersionInfo(returnList);
|
||||||
ServiceUtils.buildProjectInfo(returnList);
|
ServiceUtils.buildProjectInfo(returnList);
|
||||||
buildUserInfo(returnList);
|
buildUserInfo(returnList);
|
||||||
|
buildCustomField(returnList);
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue