fix(用例管理): 用例管理多个需求时,高级搜索不包含条件搜索结果有误

--bug=1046945 --user=陈建星 【高级搜索】用例列表筛选,用例关联多个需求时,条件:关联需求 不包含/不等于 关键字 查询到的结果错误 https://www.tapd.cn/55049933/s/1583718
This commit is contained in:
AgAngle 2024-09-23 15:20:13 +08:00 committed by Craftsman
parent 9bc12b7b7f
commit 30c12a8796
1 changed files with 45 additions and 10 deletions

View File

@ -185,18 +185,26 @@
</when>
<otherwise>
(
${mainIdColumn}
<if test="${condition}.operator == 'NOT_IN' or ${condition}.operator == 'NOT_EQUALS' or ${condition}.operator == 'NOT_CONTAINS'">
${mainIdColumn} not in (
select ${associationIdColumn} from ${associationTable} where
${searchColumn} is not null and ${searchColumn} != ''
) or
not
</if>
${mainIdColumn} in (
select ${associationIdColumn} from ${associationTable} where
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="${condition}"/>
<property name="column" value="${searchColumn}"/>
</include>
in (
select ${associationIdColumn} from ${associationTable} where
<choose>
<when test="${condition}.operator == 'NOT_IN' or ${condition}.operator == 'NOT_EQUALS' or ${condition}.operator == 'NOT_CONTAINS'">
<include refid="io.metersphere.system.mapper.BaseMapper.associationReversalCondition">
<property name="condition" value="${condition}"/>
<property name="column" value="${searchColumn}"/>
</include>
</when>
<otherwise>
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="${condition}"/>
<property name="column" value="${searchColumn}"/>
</include>
</otherwise>
</choose>
)
)
</otherwise>
@ -274,6 +282,33 @@
</trim>
</sql>
<sql id="associationReversalCondition">
<trim prefix="(" suffix=")">
<choose>
<when test="${condition}.operator == 'NOT_CONTAINS'">
<foreach collection="${condition}.value.split(' ')" item="item" separator="and">
${column} like CONCAT('%', #{item},'%')
</foreach>
</when>
<when test="${condition}.operator == 'NOT_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_EQUALS'">
${column} = #{condition.value}
</when>
</choose>
</trim>
</sql>
<sql id="queryType">
<choose>
<when test="${searchMode} == 'AND'">