feat(接口测试): 接口场景列表高级搜索

--task=1016534 --user=宋昌昌 高级筛选-接口测试-接口场景首页 https://www.tapd.cn/55049933/s/1589497
This commit is contained in:
song-cc-rock 2024-10-09 14:51:23 +08:00 committed by Craftsman
parent 88709f9564
commit 542700f3c5
4 changed files with 101 additions and 89 deletions

View File

@ -11,13 +11,17 @@ import io.metersphere.project.dto.NodeSortQueryParam;
import io.metersphere.request.AssociateOtherCaseRequest; import io.metersphere.request.AssociateOtherCaseRequest;
import io.metersphere.request.TestCasePageProviderRequest; import io.metersphere.request.TestCasePageProviderRequest;
import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.interceptor.BaseConditionFilter;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
public interface ExtApiScenarioMapper { public interface ExtApiScenarioMapper {
@BaseConditionFilter
List<ApiScenarioDTO> list(@Param("request") ApiScenarioPageRequest request, @Param("isRepeat") boolean isRepeat, @Param("testPlanId") String testPlanId); List<ApiScenarioDTO> list(@Param("request") ApiScenarioPageRequest request, @Param("isRepeat") boolean isRepeat, @Param("testPlanId") String testPlanId);
@BaseConditionFilter
List<String> getIds(@Param("request") ApiScenarioBatchRequest request, @Param("deleted") boolean deleted); List<String> getIds(@Param("request") ApiScenarioBatchRequest request, @Param("deleted") boolean deleted);
List<ApiScenario> getInfoByIds(@Param("ids") List<String> ids, @Param("deleted") boolean deleted); List<ApiScenario> getInfoByIds(@Param("ids") List<String> ids, @Param("deleted") boolean deleted);

View File

@ -153,6 +153,9 @@
<include refid="filters"> <include refid="filters">
<property name="filter" value="request.condition.filter"/> <property name="filter" value="request.condition.filter"/>
</include> </include>
<include refid="combine">
<property name="combineSearch" value="request.condition.combineSearch"/>
</include>
</sql> </sql>
<sql id="queryWhereCondition"> <sql id="queryWhereCondition">
@ -178,15 +181,9 @@
<include refid="filters"> <include refid="filters">
<property name="filter" value="request.filter"/> <property name="filter" value="request.filter"/>
</include> </include>
<if test="request.combine != null and request.combine != ''">
<include refid="combine"> <include refid="combine">
<property name="condition" value="request.combine"/> <property name="combineSearch" value="request.combineSearch"/>
<property name="name" value="request.name"/>
<property name="ObjectTags" value="request.combine.tags"/>
</include> </include>
</if>
<include refid="queryVersionCondition"> <include refid="queryVersionCondition">
<property name="versionTable" value="api_scenario"/> <property name="versionTable" value="api_scenario"/>
</include> </include>
@ -293,93 +290,100 @@
</sql> </sql>
<sql id="combine"> <sql id="combine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'> <trim prefix="AND">
and api_scenario.name <trim prefix="(" suffix=")" suffixOverrides="AND|OR">
<if test="${combineSearch} != null">
<foreach collection="${combineSearch}.userViewConditions" item="condition">
<if test="condition.name == 'createUser'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.name"/> <property name="condition" value="condition"/>
<property name="column" value="api_scenario.create_user"/>
</include> </include>
</if> </if>
<if test="condition.name == 'follower'">
<if test='${condition}.id != null'> <include refid="io.metersphere.system.mapper.BaseMapper.associationCondition">
and api_scenario.num <property name="mainIdColumn" value="api_scenario.id"/>
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <property name="associationTable" value="api_scenario_follower"/>
<property name="object" value="${condition}.id"/> <property name="associationIdColumn" value="api_scenario_id"/>
<property name="searchColumn" value="user_id"/>
<property name="condition" value="condition"/>
</include> </include>
</if> </if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<if test="${condition}.updateTime != null"> <property name="searchMode" value="${combineSearch}.searchMode"/>
and api_scenario.update_time </include>
</foreach>
<foreach collection="${combineSearch}.systemFieldConditions" item="condition">
<include refid="io.metersphere.system.mapper.BaseMapper.commonSystemFieldConditions">
<property name="condition" value="condition"/>
<property name="tablePrefix" value="api_scenario"/>
</include>
<!-- 场景等级 -->
<if test="condition.name == 'priority'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.updateTime"/> <property name="condition" value="condition"/>
<property name="column" value="api_scenario.priority"/>
</include> </include>
</if> </if>
<!-- 状态 -->
<if test="${condition}.createTime != null"> <if test="condition.name == 'status'">
and api_scenario.create_time
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.createTime"/> <property name="condition" value="condition"/>
<property name="column" value="api_scenario.status"/>
</include> </include>
</if> </if>
<!-- 执行结果 -->
<if test="${condition}.status != null"> <if test="condition.name == 'lastReportStatus'">
and api_scenario.status
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.status"/> <property name="condition" value="condition"/>
<property name="column" value="api_scenario.last_report_status"/>
</include> </include>
</if> </if>
<!-- 步骤数 -->
<if test='${condition}.tags != null and ${ObjectTags}.operator == "not like"'> <if test="condition.name == 'stepTotal'">
and (api_scenario.tags is null or api_scenario.tags
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.tags"/> <property name="condition" value="condition"/>
</include> <property name="column" value="api_scenario.step_total"/>
)
</if>
<if test='${condition}.tags != null and ${ObjectTags}.operator == "like"'>
and api_scenario.tags
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.tags"/>
</include> </include>
</if> </if>
<!-- 步骤数 -->
<if test="${condition}.customs != null and ${condition}.customs.size() > 0"> <if test="condition.name == 'stepTotal'">
<foreach collection="${condition}.customs" item="custom" separator="" open="" close=""> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<if test="custom.value != ''"> <property name="condition" value="condition"/>
<if test='custom.operator == "not like" or custom.operator == "not in"'> <property name="column" value="api_scenario.step_total"/>
and api_scenario.id not in ( </include>
</if> </if>
<if test='custom.operator != "not like" and custom.operator != "not in"'> <!-- 通过率 -->
and api_scenario.id in ( <if test="condition.name == 'passRate'">
</if>
select api_id from api_definition_custom_field where field_id = #{custom.id}
<choose> <choose>
<when test="custom.type == 'TEXTAREA' or custom.operator == 'current user'"> <when test="condition.operator == 'NOT_EMPTY'">
and `value` api_scenario.request_pass_rate is not null and api_scenario.request_pass_rate != '' and api_scenario.request_pass_rate != 'Calculating'
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="custom"/>
</include>
</when> </when>
<when test="custom.type == 'MULTIPLE_MEMBER' or custom.type == 'CHECKBOX' or custom.type == 'MULTIPLE_SELECT'"> <when test="condition.operator == 'EMPTY'">
and ${custom.value} api_scenario.request_pass_rate is null or api_scenario.request_pass_rate == '' or api_scenario.request_pass_rate == 'Calculating'
</when> </when>
<when test="custom.type == 'DATE' or custom.type == 'DATETIME'"> <when test="(condition.operator == 'LT' and condition.value == 0) or (condition.operator == 'GT' and condition.value &gt; 100 )">
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13) 1=2
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="custom"/>
</include>
</when> </when>
<otherwise> <otherwise>
and trim(both '"' from `value`) api_scenario.request_pass_rate ${condition.operator} #{condition.value}
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="custom"/>
</include>
</otherwise> </otherwise>
</choose> </choose>
)
</if> </if>
<!-- 环境 -->
<if test="condition.name == 'env'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="api_scenario.environment_id"/>
</include>
</if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
</foreach> </foreach>
</if> </if>
</trim>
</trim>
</sql> </sql>
<sql id="queryVersionCondition"> <sql id="queryVersionCondition">

View File

@ -683,6 +683,7 @@
<property name="column" value="atc.last_report_status"/> <property name="column" value="atc.last_report_status"/>
</include> </include>
</if> </if>
<!-- 接口存在更新 -->
<if test="condition.name == 'apiChange'"> <if test="condition.name == 'apiChange'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/> <property name="condition" value="condition"/>

View File

@ -6,6 +6,9 @@ import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
/**
* @author song-cc-rock
*/
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class BugPageRequest extends BasePageRequest { public class BugPageRequest extends BasePageRequest {