refactor(用例评审): 评审详情列表查询
This commit is contained in:
parent
55a6ecae3b
commit
c978deefc0
|
@ -35,7 +35,7 @@
|
|||
crfc.case_id as caseId,
|
||||
crfc.`status` as status,
|
||||
crfc.create_time as createTime,
|
||||
crfc.create_user as createUser,
|
||||
functional_case.create_user as createUser,
|
||||
user.name as createUserName,
|
||||
functional_case.version_id as versionId,
|
||||
functional_case.module_id as moduleId,
|
||||
|
@ -45,23 +45,14 @@
|
|||
FROM
|
||||
case_review_functional_case crfc
|
||||
LEFT JOIN functional_case ON crfc.case_id = functional_case.id
|
||||
LEFT JOIN user ON crfc.create_user = user.id
|
||||
LEFT JOIN user ON functional_case.create_user = user.id
|
||||
WHERE
|
||||
review_id = #{request.reviewId}
|
||||
AND functional_case.deleted = #{deleted}
|
||||
<if test="userId != null and userId != ''">
|
||||
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
||||
</if>
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
AND <include refid="queryWhereCondition"/>
|
||||
</when>
|
||||
<when test='request.searchMode == "OR"'>
|
||||
and (
|
||||
<include refid="queryWhereCondition"/>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
order by
|
||||
<if test="sort != null and sort != ''">
|
||||
functional_case.${sort}
|
||||
|
@ -75,35 +66,31 @@
|
|||
|
||||
<sql id="queryWhereCondition">
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
functional_case.module_id in
|
||||
and functional_case.module_id in
|
||||
<foreach collection="request.moduleIds" item="moduleId" separator="," open="(" close=")">
|
||||
#{moduleId}
|
||||
</foreach>
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="request.searchMode"/>
|
||||
</include>
|
||||
</if>
|
||||
<if test="request.keyword != null">
|
||||
(
|
||||
and (
|
||||
functional_case.name like concat('%', #{request.keyword},'%')
|
||||
or functional_case.num like concat('%', #{request.keyword},'%')
|
||||
or JSON_CONTAINS(tags, concat('["',#{request.keyword},'"]'))
|
||||
)
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="request.searchMode"/>
|
||||
</include>
|
||||
</if>
|
||||
<include refid="filters">
|
||||
<property name="filter" value="request.filter"/>
|
||||
<property name="searchMode" value="request.searchMode"/>
|
||||
</include>
|
||||
<if test="request.combine != null">
|
||||
<include refid="combine">
|
||||
<property name="condition" value="request.combine"/>
|
||||
<property name="searchMode" value="request.searchMode"/>
|
||||
</include>
|
||||
</if>
|
||||
1=1
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
AND <include refid="queryCombine"/>
|
||||
</when>
|
||||
<when test='request.searchMode == "OR"'>
|
||||
and (
|
||||
<include refid="queryCombine"/>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
|
||||
|
@ -113,52 +100,34 @@
|
|||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key=='status'">
|
||||
crfc.status in
|
||||
and crfc.status in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="key=='last_execute_result'">
|
||||
functional_case.last_execute_result in
|
||||
and functional_case.last_execute_result in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="key=='version_id'">
|
||||
functional_case.version_id in
|
||||
and functional_case.version_id in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="key.startsWith('custom_single')">
|
||||
test_case.id in (
|
||||
and functional_case.id in (
|
||||
select resource_id from custom_field_test_case where concat('custom_single-',field_id) =
|
||||
#{key}
|
||||
and trim(both '"' from `value`) in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
)
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="key.startsWith('custom_multiple')">
|
||||
test_case.id in (
|
||||
and functional_case.id in (
|
||||
select resource_id from custom_field_test_case where concat('custom_multiple-',field_id) =
|
||||
#{key}
|
||||
and JSON_CONTAINS(`value`, json_array(#{value}))
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</when>
|
||||
<when test="key=='create_user'">
|
||||
functional_case.create_user in
|
||||
and functional_case.create_user in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
@ -166,7 +135,18 @@
|
|||
</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">
|
||||
|
@ -176,6 +156,7 @@
|
|||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- id -->
|
||||
<if test='${condition}.id != null'>
|
||||
functional_case.num
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
|
||||
|
@ -185,6 +166,63 @@
|
|||
<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} (
|
||||
|
@ -225,6 +263,37 @@
|
|||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="queryTag">
|
||||
<!-- 不包含 -->
|
||||
<if test='${combineTag}.value.size() > 0 and ${combineTag}.operator == "not like"'>
|
||||
(
|
||||
functional_case.tags is null or functional_case.tags = '[]' or
|
||||
<foreach collection="${combineTag}.value" item="tag" separator="and" open="(" close=")">
|
||||
!JSON_CONTAINS(functional_case.tags, JSON_ARRAY(#{tag}))
|
||||
</foreach>
|
||||
)
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 包含 -->
|
||||
<if test='${combineTag}.value.size() > 0 and ${combineTag}.operator == "like"'>
|
||||
<foreach collection="${combineTag}.value" item="tag" separator="or" open="(" close=")">
|
||||
JSON_CONTAINS(functional_case.tags, JSON_ARRAY(#{tag}))
|
||||
</foreach>
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</if>
|
||||
<!-- 空 -->
|
||||
<if test='${combineTag}.operator == "is null"'>
|
||||
(functional_case.tags is null or functional_case.tags = '[]')
|
||||
<include refid="queryType">
|
||||
<property name="searchMode" value="${searchMode}"/>
|
||||
</include>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getIds" resultType="java.lang.String">
|
||||
SELECT
|
||||
crfc.id as id
|
||||
|
@ -391,16 +460,7 @@
|
|||
<if test="userId != null and userId != ''">
|
||||
AND crfc.case_id in (select crfcu.case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
||||
</if>
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
AND <include refid="queryWhereCondition"/>
|
||||
</when>
|
||||
<when test='request.searchMode == "OR"'>
|
||||
and (
|
||||
<include refid="queryWhereCondition"/>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
GROUP BY module_id
|
||||
</select>
|
||||
|
||||
|
@ -413,16 +473,7 @@
|
|||
<if test="userId != null and userId != ''">
|
||||
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
||||
</if>
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
AND <include refid="queryWhereCondition"/>
|
||||
</when>
|
||||
<when test='request.searchMode == "OR"'>
|
||||
and (
|
||||
<include refid="queryWhereCondition"/>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
@ -462,17 +462,6 @@
|
|||
</if>
|
||||
</sql>
|
||||
|
||||
<sql id="prefixMode">
|
||||
<choose>
|
||||
<when test='${searchMode} == "AND"'>
|
||||
1 = 1
|
||||
</when>
|
||||
<when test='${searchMode} == "OR"'>
|
||||
1 = 2
|
||||
</when>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="queryType">
|
||||
<choose>
|
||||
<when test='${searchMode} == "AND"'>
|
||||
|
|
Loading…
Reference in New Issue