feat(功能用例): 评审详情页面高级搜索

--task=1016128 --user=陈建星 高级搜索-视图增删改查-后端 https://www.tapd.cn/55049933/s/1573254
This commit is contained in:
AgAngle 2024-09-06 22:03:25 +08:00 committed by jianxing
parent e3f971c17f
commit 3781f72523
7 changed files with 149 additions and 173 deletions

View File

@ -423,6 +423,7 @@
select api_id from api_definition_custom_field where
<include refid="io.metersphere.system.mapper.BaseMapper.customFiledConditions">
<property name="conditions" value="${combineSearch}.customFiledConditions"/>
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
)
</if>

View File

@ -7,6 +7,7 @@ import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
import io.metersphere.functional.request.FunctionalCaseReviewListRequest;
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
import io.metersphere.system.interceptor.BaseConditionFilter;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -15,13 +16,14 @@ import java.util.List;
* @author guoyuqi
*/
public interface ExtCaseReviewFunctionalCaseMapper {
@BaseConditionFilter
List<FunctionalCaseReviewDTO> list(@Param("request") FunctionalCaseReviewListRequest request);
void updateStatus(@Param("caseId") String caseId, @Param("reviewId") String reviewId, @Param("status") String status);
List<String> getCaseIdsByReviewId(@Param("reviewId") String reviewId);
@BaseConditionFilter
List<ReviewFunctionalCaseDTO> page(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId, @Param("sort") String sort);
Long getPos(@Param("reviewId") String reviewId);
@ -30,8 +32,10 @@ public interface ExtCaseReviewFunctionalCaseMapper {
Long getLastPos(@Param("reviewId") String reviewId, @Param("basePos") Long basePos);
@BaseConditionFilter
List<String> getIds(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted);
@BaseConditionFilter
List<CaseReviewFunctionalCase> getListByRequest(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted);
List<CaseReviewFunctionalCase> getList(@Param("reviewId") String reviewId, @Param("reviewIds") List<String> reviewIds, @Param("deleted") boolean deleted);
@ -41,8 +45,10 @@ public interface ExtCaseReviewFunctionalCaseMapper {
List<CaseReviewFunctionalCase> getCaseIdsByIds(@Param("ids") List<String> ids);
@BaseConditionFilter
List<FunctionalCaseModuleCountDTO> countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId);
@BaseConditionFilter
long caseCount(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId);
}

View File

@ -84,17 +84,10 @@
<include refid="filters">
<property name="filter" value="request.filter"/>
</include>
<choose>
<when test='request.searchMode == "AND"'>
AND
<include refid="queryCombine"/>
</when>
<when test='request.searchMode == "OR"'>
and (
<include refid="queryCombine"/>
)
</when>
</choose>
<include refid="combine">
<property name="combineSearch" value="request.combineSearch"/>
</include>
</sql>
@ -145,121 +138,111 @@
</if>
</sql>
<sql id="queryCombine">
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
<property name="searchMode" value="request.searchMode"/>
</include>
</if>
1=1
</sql>
<sql id="combine">
<!-- 名称 -->
<if test='${condition}.name != null'>
functional_case.name
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.name"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- id -->
<if test='${condition}.id != null'>
functional_case.num
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.id"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 所属模块 -->
<if test='${condition}.moduleId != null'>
functional_case.moduleId
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.moduleId"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 创建人 -->
<if test='${condition}.createUser != null'>
functional_case.create_user
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.createUser"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 创建时间 -->
<if test='${condition}.createTime != null'>
functional_case.create_time
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.createTime"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 更新人 -->
<if test='${condition}.updateUser != null'>
functional_case.update_user
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.updateUser"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 更新时间 -->
<if test='${condition}.updateTime != null'>
functional_case.update_time
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="${condition}.updateTime"/>
</include>
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</if>
<!-- 标签 -->
<if test='${condition}.tags != null'>
<include refid="queryTag">
<property name="searchMode" value="${searchMode}"/>
<property name="combineTag" value="${condition}.tags"/>
</include>
</if>
<if test="${condition}.customs != null and ${condition}.customs.size() > 0">
<foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
functional_case.id ${custom.operator} (
select case_id from functional_case_custom_field where field_id = #{custom.id}
<choose>
<when test="custom.type == 'List'">
and JSON_CONTAINS(`value`, json_array(#{custom.value}))
</when>
<when test="custom.type == 'date' or custom.type == 'datetime'">
and `value`
<trim prefix="AND" suffixOverrides="AND|OR">
<if test="${combineSearch} != null">
<foreach collection="${combineSearch}.userViewConditions" item="condition">
<if test="condition.name == 'follower'">
functional_case.id in (
select case_id from functional_case_follower where
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="custom"/>
<property name="condition" value="condition"/>
<property name="column" value="user_id"/>
</include>
</when>
<otherwise>
and trim(both '"' from `value`)
)
</if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
</foreach>
<foreach collection="${combineSearch}.systemFieldConditions" item="condition">
<if test="condition.name == 'name'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="object" value="custom"/>
<property name="condition" value="condition"/>
<property name="column" value="functional_case.name"/>
</include>
</otherwise>
</choose>
)
<include refid="queryType">
<property name="searchMode" value="${searchMode}"/>
</include>
</foreach>
</if>
</if>
<if test="condition.name == 'num'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="functional_case.num"/>
</include>
</if>
<if test="condition.name == 'moduleId'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="functional_case.module_id"/>
</include>
</if>
<if test="condition.name == 'tags'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="functional_case.tags"/>
</include>
</if>
<if test="condition.name == 'createUser'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="crfc.create_User"/>
</include>
</if>
<if test="condition.name == 'updateUser'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="crfc.update_user"/>
</include>
</if>
<if test="condition.name == 'updateTime'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="crfc.update_time"/>
</include>
</if>
<if test="condition.name == 'createTime'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="crfc.create_time"/>
</include>
</if>
<if test="condition.name == 'status'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="crfc.status"/>
</include>
</if>
<if test="condition.name == 'demand'">
functional_case.id in (
select case_id from functional_case_demand where
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="demand_name"/>
</include>
)
</if>
<if test="condition.name == 'attachment'">
functional_case.id in (
select case_id from functional_case_attachment where
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="file_name"/>
</include>
)
</if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
</foreach>
<if test="${combineSearch}.customFiledConditions.size() > 0">
functional_case.id in (
select case_id from functional_case_custom_field where
<include refid="io.metersphere.system.mapper.BaseMapper.customFiledConditions">
<property name="conditions" value="${combineSearch}.customFiledConditions"/>
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
)
</if>
</if>
</trim>
</sql>
<sql id="queryType">
@ -360,30 +343,11 @@
<include refid="filters">
<property name="filter" value="request.condition.filter"/>
</include>
<choose>
<when test='request.condition.searchMode == "AND"'>
AND
<include refid="baseQueryCombine"/>
</when>
<when test='request.condition.searchMode == "OR"'>
and (
<include refid="baseQueryCombine"/>
)
</when>
</choose>
<include refid="combine">
<property name="combineSearch" value="request.condition.combineSearch"/>
</include>
</sql>
<sql id="baseQueryCombine">
<if test="request.condition.combine != null">
<include refid="combine">
<property name="condition" value="request.condition.combine"/>
<property name="searchMode" value="request.condition.searchMode"/>
</include>
</if>
1=1
</sql>
<select id="getPos" resultType="java.lang.Long">
SELECT pos
FROM case_review_functional_case

View File

@ -342,6 +342,7 @@
select case_id from functional_case_custom_field where
<include refid="io.metersphere.system.mapper.BaseMapper.customFiledConditions">
<property name="conditions" value="${combineSearch}.customFiledConditions"/>
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
)
</if>

View File

@ -10,6 +10,8 @@ import io.metersphere.functional.mapper.CaseReviewHistoryMapper;
import io.metersphere.functional.request.*;
import io.metersphere.functional.service.CaseReviewFunctionalCaseService;
import io.metersphere.sdk.constants.SessionConstants;
import io.metersphere.sdk.dto.CombineCondition;
import io.metersphere.sdk.dto.CombineSearch;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.base.BaseTest;
@ -94,17 +96,21 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
request.setCurrent(1);
request.setPageSize(10);
request.setReviewId("wx_review_id_1");
Map<String, Object> map = new HashMap<>();
map.put("customs", Arrays.asList(new LinkedHashMap() {{
put("id", "TEST_FIELD_ID");
put("operator", "in");
put("value", "222");
put("type", "List");
}}));
request.setCombine(map);
request.setCombineSearch(getCustomCombineSearch());
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
}
private CombineSearch getCustomCombineSearch() {
CombineSearch combineSearch = new CombineSearch();
CombineCondition condition = new CombineCondition();
condition.setCustomField(true);
condition.setName("TEST_FIELD_ID");
condition.setOperator(CombineCondition.CombineConditionOperator.IN.name());
condition.setValue(List.of("222"));
combineSearch.setConditions(List.of(condition));
return combineSearch;
}
@Test
@Order(3)
@ -123,14 +129,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request);
request.setReviewId("wx_review_id_1");
Map<String, Object> map = new HashMap<>();
map.put("customs", Arrays.asList(new LinkedHashMap() {{
put("id", "TEST_FIELD_ID");
put("operator", "in");
put("value", "222");
put("type", "List");
}}));
request.setCombine(map);
request.setCombineSearch(getCustomCombineSearch());
request.setViewFlag(true);
request.setViewStatusFlag(true);
this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request);
@ -206,15 +205,8 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
request.setSelectIds(new ArrayList<>());
request.setSelectAll(true);
request.setExcludeIds(Arrays.asList("TEST_FUNCTIONAL_CASE_ID_1"));
Map<String, Object> map = new HashMap<>();
map.put("customs", Arrays.asList(new LinkedHashMap() {{
put("id", "TEST_FIELD_ID");
put("operator", "in");
put("value", "222");
put("type", "List");
}}));
BaseCondition baseCondition = new BaseCondition();
baseCondition.setCombine(map);
baseCondition.setCombineSearch(getCustomCombineSearch());
request.setCondition(baseCondition);
this.requestPostWithOkAndReturn(BATCH_DELETE_URL, request);

View File

@ -491,8 +491,8 @@ public class FunctionalCaseControllerTests extends BaseTest {
condition.setCustomField(true);
condition.setName("TEST_FIELD_ID");
condition.setOperator(CombineCondition.CombineConditionOperator.IN.name());
condition.setValue("222");
combineSearch.setConditions(List.of());
condition.setValue(List.of("222"));
combineSearch.setConditions(List.of(condition));
request.setCombineSearch(combineSearch);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_LIST_URL, request);
Pager<List<FunctionalCasePageDTO>> tableData = JSON.parseObject(JSON.toJSONString(

View File

@ -65,7 +65,7 @@
</include>
</trim>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="request.combineSearch.searchMode"/>
<property name="searchMode" value="${searchMode}"/>
</include>
</foreach>
</trim>
@ -81,13 +81,25 @@
${column} not like CONCAT('%', #{condition.value},'%')
</when>
<when test="${condition}.operator == 'IN'">
${column} in
<if test="'${column}' == 'value'">
`value`
</if>
<if test="'${column}' != 'value'">
${column}
</if>
in
<foreach collection="${condition}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test="${condition}.operator == 'NOT_IN'">
${column} not in
<if test="'${column}' == 'value'">
`value`
</if>
<if test="'${column}' != 'value'">
${column}
</if>
not in
<foreach collection="${condition}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>