feat(测试计划): 测试计划列表增加高级搜索

This commit is contained in:
WangXu10 2024-11-04 15:46:13 +08:00 committed by Craftsman
parent bd07a77b2c
commit 935c1d652e
7 changed files with 105 additions and 21 deletions

View File

@ -597,4 +597,5 @@ user_view.all_data=All data
user_view.my_follow=I followed
user_view.my_create=I created
user_view.my_review=I review
user_view.archived=Archived
user_view_exist=The view already exists

View File

@ -592,4 +592,5 @@ user_view.all_data=全部数据
user_view.my_follow=我关注的
user_view.my_create=我创建的
user_view.my_review=我评审的
user_view.archived=已归档
user_view_exist=视图已存在

View File

@ -592,4 +592,5 @@ user_view.all_data=全部數據
user_view.my_follow=我關注的
user_view.my_create=我創建的
user_view.my_review=我評審的
user_view.archived=已歸檔
user_view_exist=視圖已存在

View File

@ -44,6 +44,15 @@ public enum InternalUserView {
condition.setOperator(CombineCondition.CombineConditionOperator.IN.name());
userViewDTO.setConditions(List.of(condition));
return userViewDTO;
}),
ARCHIVED(() -> {
UserViewDTO userViewDTO = getUserViewDTO("archived");
CombineCondition condition = new CombineCondition();
condition.setName("archived");
condition.setValue("ARCHIVED");
condition.setOperator(CombineCondition.CombineConditionOperator.EQUALS.name());
userViewDTO.setConditions(List.of(condition));
return userViewDTO;
});
private static UserViewDTO getUserViewDTO(String name) {

View File

@ -8,10 +8,9 @@ import java.util.List;
/**
* @Author: jianxing
* @CreateTime: 2024-09-02 10:47
*
* <p>
* 视图的类型
* 例如功能用例视图
*
*/
public enum UserViewType implements ValueEnum {
@ -54,8 +53,23 @@ public enum UserViewType implements ValueEnum {
PLAN_API_SCENARIO_DRAWER("plan-api-scenario-drawer",
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE)),
PLAN_BUG_DRAWER("plan-bug-drawer",
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE));
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE)),
/**
* 测试计划列表
*/
TEST_PLAN_ALL("test-plan-all",
List.of(InternalUserView.ALL_DATA, InternalUserView.ARCHIVED, InternalUserView.MY_CREATE)),
TEST_PLAN("test-plan",
List.of(InternalUserView.ALL_DATA, InternalUserView.ARCHIVED, InternalUserView.MY_FOLLOW, InternalUserView.MY_CREATE)),
TEST_PLAN_GROUP("test-plan-group",
List.of(InternalUserView.ALL_DATA, InternalUserView.ARCHIVED, InternalUserView.MY_CREATE)),
/**
* 测试计划报告
*/
TEST_PLAN_REPORT("test-plan-report",
List.of(InternalUserView.ALL_DATA, InternalUserView.MY_CREATE));
private String value;
private List<InternalUserView> internalViews;

View File

@ -11,6 +11,7 @@ import io.metersphere.plan.dto.response.TestPlanResponse;
import io.metersphere.project.dto.DropNode;
import io.metersphere.project.dto.ModuleCountDTO;
import io.metersphere.project.dto.NodeSortQueryParam;
import io.metersphere.system.interceptor.BaseConditionFilter;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -20,6 +21,7 @@ public interface ExtTestPlanMapper {
List<String> selectByGroupIdList(@Param("list") List<String> parentTestPlanId);
@BaseConditionFilter
List<TestPlanResponse> selectByConditions(@Param("request") TestPlanTableRequest request);
List<String> selectIdByConditions(@Param("request") TestPlanBatchProcessRequest request);

View File

@ -113,7 +113,7 @@
</foreach>
</if>
<choose>
<!--<choose>
<when test='request.searchMode == "AND"'>
AND <include refid="queryCombine"/>
</when>
@ -122,11 +122,13 @@
<include refid="queryCombine"/>
)
</when>
</choose>
</choose>-->
<include refid="filters">
<property name="filter" value="request.filter"/>
</include>
<include refid="combine">
<property name="combineSearch" value="request.combineSearch"/>
</include>
</sql>
@ -147,7 +149,61 @@
</sql>
<sql id="queryCombine">
<sql id="combine">
<trim prefix="AND">
<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">
<property name="condition" value="condition"/>
<property name="column" value="t.create_user"/>
</include>
</if>
<if test="condition.name == 'follower'">
<include refid="io.metersphere.system.mapper.BaseMapper.associationCondition">
<property name="mainIdColumn" value="t.id"/>
<property name="associationTable" value="test_plan_follower"/>
<property name="associationIdColumn" value="test_plan_id"/>
<property name="searchColumn" value="user_id"/>
<property name="condition" value="condition"/>
</include>
</if>
<if test="condition.name == 'archived'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="t.status"/>
</include>
</if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</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="t"/>
</include>
<!-- 状态 -->
<if test="condition.name == 'status'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="t.status"/>
</include>
</if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
</foreach>
</if>
</trim>
</trim>
</sql>
<!-- <sql id="queryCombine">
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
@ -158,7 +214,7 @@
</sql>
<sql id="combine">
<!-- 名称 -->
&lt;!&ndash; 名称 &ndash;&gt;
<if test='${condition}.name != null'>
t.name
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
@ -168,7 +224,7 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- id -->
&lt;!&ndash; id &ndash;&gt;
<if test='${condition}.id != null'>
t.num
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
@ -178,7 +234,7 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 所属模块 -->
&lt;!&ndash; 所属模块 &ndash;&gt;
<if test='${condition}.moduleId != null'>
t.moduleId
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
@ -188,7 +244,7 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 创建人 -->
&lt;!&ndash; 创建人 &ndash;&gt;
<if test='${condition}.createUser != null'>
t.create_user
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
@ -198,7 +254,7 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 创建时间 -->
&lt;!&ndash; 创建时间 &ndash;&gt;
<if test='${condition}.createTime != null'>
t.create_time
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
@ -208,16 +264,16 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 标签 -->
&lt;!&ndash; 标签 &ndash;&gt;
<if test='${condition}.tags != null'>
<include refid="queryTag">
<property name="searchMode" value="${searchMode}"/>
<property name="combineTag" value="${condition}.tags"/>
</include>
</if>
</sql>
</sql>-->
<sql id="queryType">
<!--<sql id="queryType">
<choose>
<when test='${searchMode} == "AND"'>
AND
@ -226,11 +282,11 @@
OR
</when>
</choose>
</sql>
</sql>-->
<sql id="queryTag">
<!-- 不包含 -->
<!--<sql id="queryTag">
&lt;!&ndash; 不包含 &ndash;&gt;
<if test='${combineTag}.value.size() > 0 and ${combineTag}.operator == "not like"'>
(
t.tags is null or t.tags = '[]' or
@ -242,7 +298,7 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 包含 -->
&lt;!&ndash; 包含 &ndash;&gt;
<if test='${combineTag}.value.size() > 0 and ${combineTag}.operator == "like"'>
<foreach collection="${combineTag}.value" item="tag" separator="or" open="(" close=")">
JSON_CONTAINS(t.tags, JSON_ARRAY(#{tag}))
@ -251,14 +307,14 @@
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!---->
&lt;!&ndash;&ndash;&gt;
<if test='${combineTag}.operator == "is null"'>
(t.tags is null or t.tags = '[]')
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
</sql>
</sql>-->
<select id="countModuleIdByConditions"