fix(测试用例): 接口定义高级搜索,用例数搜索报错

--bug=1046336 --user=陈建星 【接口测试】定义-筛选-选中所有字段筛选后提示sql异常 https://www.tapd.cn/55049933/s/1578782
This commit is contained in:
AgAngle 2024-09-14 11:51:38 +08:00 committed by jianxing
parent ace829f19b
commit bbb11660e9
3 changed files with 49 additions and 4 deletions

View File

@ -34,7 +34,7 @@ public interface ExtApiDefinitionMapper {
List<String> getIds(@Param("request") TableBatchProcessDTO request, @Param("projectId") String projectId, @Param("protocols") List<String> protocols, @Param("deleted") boolean deleted);
@BaseConditionFilter
List<String> getIdsBySort(@Param("request") TableBatchProcessDTO request, @Param("projectId") String projectId, @Param("protocols") List<String> protocols, @Param("orderColumns") String orderColumns);
List<String> getIdsBySort(@Param("request") TableBatchProcessDTO request, @Param("projectId") String projectId, @Param("protocols") List<String> protocols, @Param("orderColumns") String orderColumns, @Param("deleted") boolean deleted);
List<String> getRefIds(@Param("ids") List<String> ids, @Param("deleted") boolean deleted);

View File

@ -92,7 +92,7 @@
<select id="getIdsBySort" resultType="java.lang.String">
SELECT id
FROM api_definition
where project_id = #{projectId} and deleted is false
where project_id = #{projectId} and deleted = #{deleted}
<if test="protocols != null and protocols.size() > 0">
AND protocol in
<foreach collection="protocols" item="protocol" separator="," open="(" close=")">
@ -281,6 +281,8 @@
<include refid="combine">
<property name="combineSearch" value="request.combineSearch"/>
<property name="projectId" value="${request.projectId}"/>
<property name="deleted" value="${request.deleted}"/>
</include>
<include refid="queryVersionCondition">
@ -415,6 +417,47 @@
<property name="column" value="api_definition.path"/>
</include>
</if>
<if test="condition.name == 'caseTotal'">
<choose>
<when test="condition.operator == 'NOT_EMPTY'">
api_definition.id in (
select api_definition_id from api_test_case where deleted = ${deleted}
and project_id = '${projectId}'
)
</when>
<when test="condition.operator == 'EMPTY'">
api_definition.id not in (
select api_definition_id from api_test_case where deleted = ${deleted}
and project_id = '${projectId}'
)
</when>
<when test="(condition.operator == 'LT' and condition.value &lt; 1) or (condition.operator == 'EQUALS' and condition.value &lt; 0)">
1=2
</when>
<otherwise>
<if test="condition.operator == 'LT' or (condition.operator == 'EQUALS' and condition.value == 0)">
api_definition.id not in (
select api_definition_id from api_test_case where deleted = ${deleted}
and project_id = '${projectId}'
)
<if test="condition.value &gt; 1">
OR
</if>
</if>
<if test="(condition.operator == 'EQUALS' and condition.value &gt; 0) or (condition.operator == 'LT' and condition.value &gt; 1) or condition.operator == 'GT'">
api_definition.id in (
select api_definition_id from api_test_case where deleted = ${deleted}
and project_id = '${projectId}'
group by api_definition_id having
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="count(id)"/>
</include>
)
</if>
</otherwise>
</choose>
</if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
@ -453,8 +496,10 @@
<sql id="queryWhereConditionByBaseQueryRequest">
<include refid="combine">
<property name="combineSearch" value="request.condition.combineSearch"/>
<property name="projectId" value="${projectId}"/>
<property name="deleted" value="${deleted}"/>
</include>
<if test="request.condition.keyword != null">
<if test="request.condition.keyword != null and request.condition.keyword != ''">
and (
api_definition.num like concat('%', #{request.condition.keyword},'%')
or api_definition.name like concat('%', #{request.condition.keyword},'%')

View File

@ -210,7 +210,7 @@ public class ApiDefinitionExportService {
if (request.isSelectAll()) {
String sortString = StringUtils.isBlank(request.getSortString()) ? "pos desc,id desc" : request.getSortString();
List<String> ids = extApiDefinitionMapper.getIdsBySort(request, request.getProjectId(), protocols, sortString);
List<String> ids = extApiDefinitionMapper.getIdsBySort(request, request.getProjectId(), protocols, sortString, false);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
ids.removeAll(request.getExcludeIds());
}