refactor: 版本查询优化
This commit is contained in:
parent
1aa2f94833
commit
7adb8aeeee
|
@ -65,5 +65,7 @@ public class TestCase implements Serializable {
|
||||||
|
|
||||||
private String refId;
|
private String refId;
|
||||||
|
|
||||||
|
private Byte latest;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
|
@ -2133,6 +2133,66 @@ public class TestCaseExample {
|
||||||
addCriterion("ref_id not between", value1, value2, "refId");
|
addCriterion("ref_id not between", value1, value2, "refId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestIsNull() {
|
||||||
|
addCriterion("latest is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestIsNotNull() {
|
||||||
|
addCriterion("latest is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestEqualTo(Byte value) {
|
||||||
|
addCriterion("latest =", value, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestNotEqualTo(Byte value) {
|
||||||
|
addCriterion("latest <>", value, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestGreaterThan(Byte value) {
|
||||||
|
addCriterion("latest >", value, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestGreaterThanOrEqualTo(Byte value) {
|
||||||
|
addCriterion("latest >=", value, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestLessThan(Byte value) {
|
||||||
|
addCriterion("latest <", value, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestLessThanOrEqualTo(Byte value) {
|
||||||
|
addCriterion("latest <=", value, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestIn(List<Byte> values) {
|
||||||
|
addCriterion("latest in", values, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestNotIn(List<Byte> values) {
|
||||||
|
addCriterion("latest not in", values, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestBetween(Byte value1, Byte value2) {
|
||||||
|
addCriterion("latest between", value1, value2, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andLatestNotBetween(Byte value1, Byte value2) {
|
||||||
|
addCriterion("latest not between", value1, value2, "latest");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Criteria extends GeneratedCriteria {
|
public static class Criteria extends GeneratedCriteria {
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<result column="case_public" jdbcType="BIT" property="casePublic" />
|
<result column="case_public" jdbcType="BIT" property="casePublic" />
|
||||||
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
|
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
|
||||||
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
|
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
|
||||||
|
<result column="latest" jdbcType="TINYINT" property="latest" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs">
|
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestCaseWithBLOBs">
|
||||||
<result column="prerequisite" jdbcType="LONGVARCHAR" property="prerequisite" />
|
<result column="prerequisite" jdbcType="LONGVARCHAR" property="prerequisite" />
|
||||||
|
@ -103,7 +104,7 @@
|
||||||
id, node_id, test_id, node_path, project_id, `name`, `type`, maintainer, priority,
|
id, node_id, test_id, node_path, project_id, `name`, `type`, maintainer, priority,
|
||||||
`method`, create_time, update_time, sort, num, other_test_name, review_status, tags,
|
`method`, create_time, update_time, sort, num, other_test_name, review_status, tags,
|
||||||
demand_id, demand_name, `status`, step_model, custom_num, create_user, original_status,
|
demand_id, demand_name, `status`, step_model, custom_num, create_user, original_status,
|
||||||
delete_time, delete_user_id, `order`, case_public, version_id, ref_id
|
delete_time, delete_user_id, `order`, case_public, version_id, ref_id, latest
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
prerequisite, remark, steps, step_description, expected_result, custom_fields
|
prerequisite, remark, steps, step_description, expected_result, custom_fields
|
||||||
|
@ -167,8 +168,8 @@
|
||||||
custom_num, create_user, original_status,
|
custom_num, create_user, original_status,
|
||||||
delete_time, delete_user_id, `order`,
|
delete_time, delete_user_id, `order`,
|
||||||
case_public, version_id, ref_id,
|
case_public, version_id, ref_id,
|
||||||
prerequisite, remark, steps,
|
latest, prerequisite, remark,
|
||||||
step_description, expected_result,
|
steps, step_description, expected_result,
|
||||||
custom_fields)
|
custom_fields)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
|
||||||
#{nodePath,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
#{nodePath,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||||
|
@ -180,8 +181,8 @@
|
||||||
#{customNum,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{originalStatus,jdbcType=VARCHAR},
|
#{customNum,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{originalStatus,jdbcType=VARCHAR},
|
||||||
#{deleteTime,jdbcType=BIGINT}, #{deleteUserId,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT},
|
#{deleteTime,jdbcType=BIGINT}, #{deleteUserId,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT},
|
||||||
#{casePublic,jdbcType=BIT}, #{versionId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR},
|
#{casePublic,jdbcType=BIT}, #{versionId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR},
|
||||||
#{prerequisite,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR},
|
#{latest,jdbcType=TINYINT}, #{prerequisite,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR},
|
||||||
#{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR},
|
#{steps,jdbcType=LONGVARCHAR}, #{stepDescription,jdbcType=LONGVARCHAR}, #{expectedResult,jdbcType=LONGVARCHAR},
|
||||||
#{customFields,jdbcType=LONGVARCHAR})
|
#{customFields,jdbcType=LONGVARCHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
|
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseWithBLOBs">
|
||||||
|
@ -277,6 +278,9 @@
|
||||||
<if test="refId != null">
|
<if test="refId != null">
|
||||||
ref_id,
|
ref_id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="latest != null">
|
||||||
|
latest,
|
||||||
|
</if>
|
||||||
<if test="prerequisite != null">
|
<if test="prerequisite != null">
|
||||||
prerequisite,
|
prerequisite,
|
||||||
</if>
|
</if>
|
||||||
|
@ -387,6 +391,9 @@
|
||||||
<if test="refId != null">
|
<if test="refId != null">
|
||||||
#{refId,jdbcType=VARCHAR},
|
#{refId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="latest != null">
|
||||||
|
#{latest,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
<if test="prerequisite != null">
|
<if test="prerequisite != null">
|
||||||
#{prerequisite,jdbcType=LONGVARCHAR},
|
#{prerequisite,jdbcType=LONGVARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -506,6 +513,9 @@
|
||||||
<if test="record.refId != null">
|
<if test="record.refId != null">
|
||||||
ref_id = #{record.refId,jdbcType=VARCHAR},
|
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.latest != null">
|
||||||
|
latest = #{record.latest,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
<if test="record.prerequisite != null">
|
<if test="record.prerequisite != null">
|
||||||
prerequisite = #{record.prerequisite,jdbcType=LONGVARCHAR},
|
prerequisite = #{record.prerequisite,jdbcType=LONGVARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -561,6 +571,7 @@
|
||||||
case_public = #{record.casePublic,jdbcType=BIT},
|
case_public = #{record.casePublic,jdbcType=BIT},
|
||||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||||
ref_id = #{record.refId,jdbcType=VARCHAR},
|
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||||
|
latest = #{record.latest,jdbcType=TINYINT},
|
||||||
prerequisite = #{record.prerequisite,jdbcType=LONGVARCHAR},
|
prerequisite = #{record.prerequisite,jdbcType=LONGVARCHAR},
|
||||||
remark = #{record.remark,jdbcType=LONGVARCHAR},
|
remark = #{record.remark,jdbcType=LONGVARCHAR},
|
||||||
steps = #{record.steps,jdbcType=LONGVARCHAR},
|
steps = #{record.steps,jdbcType=LONGVARCHAR},
|
||||||
|
@ -602,7 +613,8 @@
|
||||||
`order` = #{record.order,jdbcType=BIGINT},
|
`order` = #{record.order,jdbcType=BIGINT},
|
||||||
case_public = #{record.casePublic,jdbcType=BIT},
|
case_public = #{record.casePublic,jdbcType=BIT},
|
||||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||||
ref_id = #{record.refId,jdbcType=VARCHAR}
|
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||||
|
latest = #{record.latest,jdbcType=TINYINT}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
|
@ -697,6 +709,9 @@
|
||||||
<if test="refId != null">
|
<if test="refId != null">
|
||||||
ref_id = #{refId,jdbcType=VARCHAR},
|
ref_id = #{refId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="latest != null">
|
||||||
|
latest = #{latest,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
<if test="prerequisite != null">
|
<if test="prerequisite != null">
|
||||||
prerequisite = #{prerequisite,jdbcType=LONGVARCHAR},
|
prerequisite = #{prerequisite,jdbcType=LONGVARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -749,6 +764,7 @@
|
||||||
case_public = #{casePublic,jdbcType=BIT},
|
case_public = #{casePublic,jdbcType=BIT},
|
||||||
version_id = #{versionId,jdbcType=VARCHAR},
|
version_id = #{versionId,jdbcType=VARCHAR},
|
||||||
ref_id = #{refId,jdbcType=VARCHAR},
|
ref_id = #{refId,jdbcType=VARCHAR},
|
||||||
|
latest = #{latest,jdbcType=TINYINT},
|
||||||
prerequisite = #{prerequisite,jdbcType=LONGVARCHAR},
|
prerequisite = #{prerequisite,jdbcType=LONGVARCHAR},
|
||||||
remark = #{remark,jdbcType=LONGVARCHAR},
|
remark = #{remark,jdbcType=LONGVARCHAR},
|
||||||
steps = #{steps,jdbcType=LONGVARCHAR},
|
steps = #{steps,jdbcType=LONGVARCHAR},
|
||||||
|
@ -787,7 +803,8 @@
|
||||||
`order` = #{order,jdbcType=BIGINT},
|
`order` = #{order,jdbcType=BIGINT},
|
||||||
case_public = #{casePublic,jdbcType=BIT},
|
case_public = #{casePublic,jdbcType=BIT},
|
||||||
version_id = #{versionId,jdbcType=VARCHAR},
|
version_id = #{versionId,jdbcType=VARCHAR},
|
||||||
ref_id = #{refId,jdbcType=VARCHAR}
|
ref_id = #{refId,jdbcType=VARCHAR},
|
||||||
|
latest = #{latest,jdbcType=TINYINT}
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -180,28 +180,9 @@
|
||||||
<property name="objectKey" value="request.combine.tags"/>
|
<property name="objectKey" value="request.combine.tags"/>
|
||||||
</include>
|
</include>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and ad.version_id = #{request.versionId}
|
<property name="versionTable" value="ad"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and ad.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
ad.version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = ad.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
ad.version_id = (SELECT tmp.version_id
|
|
||||||
FROM api_definition tmp
|
|
||||||
WHERE ref_id = ad.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="request.filters != null and request.filters.size() > 0">
|
<if test="request.filters != null and request.filters.size() > 0">
|
||||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||||
<if test="values != null and values.size() > 0">
|
<if test="values != null and values.size() > 0">
|
||||||
|
@ -439,30 +420,9 @@
|
||||||
#{nodeId}
|
#{nodeId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and atc.version_id = #{request.versionId}
|
<property name="versionTable" value="atc"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and atc.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
atc.version_id = (SELECT project_version.id
|
|
||||||
FROM api_scenario tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = atc.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
atc.version_id = (SELECT tmp.version_id
|
|
||||||
FROM api_scenario tmp
|
|
||||||
WHERE ref_id = atc.ref_id
|
|
||||||
GROUP BY ref_id
|
|
||||||
HAVING max(latest) = 0
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
<include refid="scenarioCombine">
|
<include refid="scenarioCombine">
|
||||||
<property name="condition" value="request.combine"/>
|
<property name="condition" value="request.combine"/>
|
||||||
|
@ -513,30 +473,9 @@
|
||||||
and (atc.name like CONCAT('%', #{request.name},'%')
|
and (atc.name like CONCAT('%', #{request.name},'%')
|
||||||
or atc.num like CONCAT('%', #{request.name},'%'))
|
or atc.num like CONCAT('%', #{request.name},'%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and atc.version_id = #{request.versionId}
|
<property name="versionTable" value="atc"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and atc.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
atc.version_id = (SELECT project_version.id
|
|
||||||
FROM load_test tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = atc.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
atc.version_id = (SELECT tmp.version_id
|
|
||||||
FROM load_test tmp
|
|
||||||
WHERE ref_id = atc.ref_id
|
|
||||||
GROUP BY ref_id
|
|
||||||
HAVING max(latest) = 0
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
<include refid="loadCaseCombine">
|
<include refid="loadCaseCombine">
|
||||||
<property name="condition" value="request.combine"/>
|
<property name="condition" value="request.combine"/>
|
||||||
|
@ -594,4 +533,16 @@
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -475,39 +475,9 @@
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and api_definition.version_id = #{request.versionId}
|
<property name="versionTable" value="api_definition"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and api_definition.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = api_definition.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM api_definition tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = api_definition.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
order by
|
order by
|
||||||
|
@ -743,39 +713,9 @@
|
||||||
and api_definition.id in
|
and api_definition.id in
|
||||||
(SELECT api_definition_id FROM api_test_case)
|
(SELECT api_definition_id FROM api_test_case)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.refId != null">
|
<include refid="queryVersionCondition">
|
||||||
AND ref_id = #{request.refId}
|
<property name="versionTable" value="api_definition"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.versionId != null">
|
|
||||||
AND version_id = #{request.versionId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = api_definition.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM api_definition tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = api_definition.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -843,39 +783,9 @@
|
||||||
and api_definition.id in
|
and api_definition.id in
|
||||||
(SELECT api_definition_id FROM api_test_case)
|
(SELECT api_definition_id FROM api_test_case)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.refId != null">
|
<include refid="queryVersionCondition">
|
||||||
AND ref_id = #{request.refId}
|
<property name="versionTable" value="api_definition"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.versionId != null">
|
|
||||||
AND version_id = #{request.versionId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = api_definition.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM api_definition tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = api_definition.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -950,4 +860,16 @@
|
||||||
<include refid="io.metersphere.base.mapper.ApiDefinitionMapper.Example_Where_Clause"/>
|
<include refid="io.metersphere.base.mapper.ApiDefinitionMapper.Example_Where_Clause"/>
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -318,39 +318,9 @@
|
||||||
where pc.test_plan_id = #{request.planId}
|
where pc.test_plan_id = #{request.planId}
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.refId != null">
|
<include refid="queryVersionCondition">
|
||||||
AND ref_id = #{request.refId}
|
<property name="versionTable" value="api_scenario"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.versionId != null">
|
|
||||||
AND version_id = #{request.versionId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_scenario tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = api_scenario.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM api_scenario tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM api_scenario tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = api_scenario.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -674,4 +644,16 @@
|
||||||
LEFT JOIN project on api_scenario.project_id = project.id
|
LEFT JOIN project on api_scenario.project_id = project.id
|
||||||
WHERE api_scenario.id = #{id}
|
WHERE api_scenario.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -419,29 +419,9 @@
|
||||||
<if test="request.toUpdate !=null and request.toUpdate == true">
|
<if test="request.toUpdate !=null and request.toUpdate == true">
|
||||||
and (t1.update_time >= #{request.updateTime} or t2.status = 'error')
|
and (t1.update_time >= #{request.updateTime} or t2.status = 'error')
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
AND t1.version_id = #{request.versionId}
|
<property name="versionTable" value="t1"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
t1.version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = a.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
t1.version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id
|
|
||||||
WHERE ref_id = a.ref_id
|
|
||||||
GROUP BY ref_id
|
|
||||||
HAVING MAX(latest) = 0
|
|
||||||
ORDER BY MAX(project_version.create_time) DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
GROUP BY t1.id,
|
GROUP BY t1.id,
|
||||||
t1.project_id,
|
t1.project_id,
|
||||||
t1.name,
|
t1.name,
|
||||||
|
@ -787,4 +767,16 @@
|
||||||
#{v}
|
#{v}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -166,39 +166,9 @@
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.refId != null">
|
<include refid="queryVersionCondition">
|
||||||
AND ref_id = #{request.refId}
|
<property name="versionTable" value="load_test"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.versionId != null">
|
|
||||||
AND version_id = #{request.versionId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM load_test tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = load_test.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM load_test tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM load_test tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = load_test.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -305,4 +275,16 @@
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -30,21 +30,9 @@
|
||||||
#{apiId}
|
#{apiId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.refId != null">
|
<include refid="queryVersionCondition">
|
||||||
AND api.ref_id = #{request.refId}
|
<property name="versionTable" value="api"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.versionId != null">
|
|
||||||
AND api.version_id = #{request.versionId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null">
|
|
||||||
AND api.version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id
|
|
||||||
WHERE ref_id = api.ref_id
|
|
||||||
ORDER BY project_version.create_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
</if>
|
|
||||||
<if test="request.orderCondition == 'createTimeDesc'">
|
<if test="request.orderCondition == 'createTimeDesc'">
|
||||||
ORDER BY api.create_time DESC
|
ORDER BY api.create_time DESC
|
||||||
</if>
|
</if>
|
||||||
|
@ -67,4 +55,15 @@
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -83,7 +83,7 @@ public interface ExtTestCaseMapper {
|
||||||
|
|
||||||
List<TrackCountResult> countRelevance(@Param("projectId") String projectId);
|
List<TrackCountResult> countRelevance(@Param("projectId") String projectId);
|
||||||
|
|
||||||
long countRelevanceCreatedThisWeek(@Param("projectId") String projectId,@Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
long countRelevanceCreatedThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||||
|
|
||||||
int countCoverage(@Param("projectId") String projectId);
|
int countCoverage(@Param("projectId") String projectId);
|
||||||
|
|
||||||
|
@ -92,13 +92,15 @@ public interface ExtTestCaseMapper {
|
||||||
List<TrackCountResult> countRelevanceMaintainer(@Param("projectId") String projectId);
|
List<TrackCountResult> countRelevanceMaintainer(@Param("projectId") String projectId);
|
||||||
|
|
||||||
int getTestPlanBug(@Param("planId") String planId);
|
int getTestPlanBug(@Param("planId") String planId);
|
||||||
|
|
||||||
int getTestPlanCase(@Param("planId") String planId);
|
int getTestPlanCase(@Param("planId") String planId);
|
||||||
|
|
||||||
int getTestPlanPassCase(@Param("planId") String planId);
|
int getTestPlanPassCase(@Param("planId") String planId);
|
||||||
|
|
||||||
|
|
||||||
List<TestCaseDTO> listForMinder(@Param("request") QueryTestCaseRequest request);
|
List<TestCaseDTO> listForMinder(@Param("request") QueryTestCaseRequest request);
|
||||||
|
|
||||||
List<TestCaseDTO> getTestCaseByIds(@Param("ids")List<String> ids);
|
List<TestCaseDTO> getTestCaseByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
void updateTestCaseCustomNumByProjectId(@Param("projectId") String projectId);
|
void updateTestCaseCustomNumByProjectId(@Param("projectId") String projectId);
|
||||||
|
|
||||||
|
@ -124,7 +126,7 @@ public interface ExtTestCaseMapper {
|
||||||
|
|
||||||
List<String> getIdsOrderByUpdateTime(@Param("projectId") String projectId);
|
List<String> getIdsOrderByUpdateTime(@Param("projectId") String projectId);
|
||||||
|
|
||||||
Long getLastOrder(@Param("projectId")String projectId, @Param("baseOrder") Long baseOrder);
|
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||||
|
|
||||||
Long getPreOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
Long getPreOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||||
|
|
||||||
|
@ -139,4 +141,10 @@ public interface ExtTestCaseMapper {
|
||||||
int countByWorkSpaceId(String workSpaceId);
|
int countByWorkSpaceId(String workSpaceId);
|
||||||
|
|
||||||
long trashCount(@Param("projectId") String projectId);
|
long trashCount(@Param("projectId") String projectId);
|
||||||
|
|
||||||
|
int addLatestVersion(@Param("refId") String refId);
|
||||||
|
|
||||||
|
int clearLatestVersion(@Param("refId") String refId);
|
||||||
|
|
||||||
|
int setLatestVersion(@Param("refId") String refId, @Param("versionId") String versionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,39 +126,9 @@
|
||||||
#{nodeId}
|
#{nodeId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and test_case.version_id = #{request.versionId}
|
<property name="versionTable" value="test_case"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and test_case.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = test_case.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM test_case tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = test_case.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<include refid="filters"/>
|
<include refid="filters"/>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
@ -642,39 +612,9 @@
|
||||||
<if test="request.caseCoverage == 'coverage' ">
|
<if test="request.caseCoverage == 'coverage' ">
|
||||||
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
|
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and test_case.version_id = #{request.versionId}
|
<property name="versionTable" value="test_case"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and test_case.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = test_case.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM test_case tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = test_case.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -733,39 +673,9 @@
|
||||||
<if test="request.caseCoverage == 'coverage' ">
|
<if test="request.caseCoverage == 'coverage' ">
|
||||||
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
|
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and test_case.version_id = #{request.versionId}
|
<property name="versionTable" value="test_case"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and test_case.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = test_case.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM test_case tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = test_case.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
@ -1057,4 +967,61 @@
|
||||||
AND STATUS = 'Trash'
|
AND STATUS = 'Trash'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<update id="addLatestVersion">
|
||||||
|
UPDATE test_case
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT
|
||||||
|
test_case.*
|
||||||
|
FROM
|
||||||
|
test_case
|
||||||
|
LEFT JOIN project_version ON test_case.version_id = project_version.id
|
||||||
|
<where>
|
||||||
|
<if test="refId != null">
|
||||||
|
ref_id = #{refId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
ref_id
|
||||||
|
HAVING
|
||||||
|
max(test_case.latest) = 0
|
||||||
|
ORDER BY
|
||||||
|
project_version.create_time desc
|
||||||
|
LIMIT 1
|
||||||
|
) t
|
||||||
|
ON test_case.id = t.id
|
||||||
|
SET test_case.latest = 1
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="clearLatestVersion">
|
||||||
|
UPDATE test_case
|
||||||
|
SET latest = 0
|
||||||
|
<where>
|
||||||
|
<if test="refId != null">
|
||||||
|
and ref_id = #{refId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="setLatestVersion">
|
||||||
|
UPDATE test_case
|
||||||
|
SET latest = 1
|
||||||
|
<where>
|
||||||
|
<if test="refId != null">
|
||||||
|
ref_id = #{refId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
AND version_id = #{versionId}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -139,32 +139,9 @@
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and a.version_id = #{request.versionId}
|
<property name="versionTable" value="a"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and a.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
a.version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = a.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
a.version_id = (SELECT project_version.id
|
|
||||||
FROM api_definition tmp
|
|
||||||
JOIN project_version ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id
|
|
||||||
WHERE ref_id = a.ref_id
|
|
||||||
GROUP BY ref_id
|
|
||||||
HAVING MAX(latest) = 0
|
|
||||||
ORDER BY MAX(project_version.create_time) DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
order by
|
order by
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
@ -371,4 +348,16 @@
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -193,32 +193,9 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and lt.version_id = #{request.versionId}
|
<property name="versionTable" value="lt"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and lt.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
lt.version_id = (SELECT project_version.id
|
|
||||||
FROM load_test tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = lt.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
lt.version_id = (SELECT project_version.id
|
|
||||||
FROM load_test tmp
|
|
||||||
JOIN project_version ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id
|
|
||||||
WHERE ref_id = lt.ref_id
|
|
||||||
GROUP BY ref_id
|
|
||||||
HAVING MAX(latest) = 0
|
|
||||||
ORDER BY MAX(project_version.create_time) DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
order by
|
order by
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
@ -371,4 +348,16 @@
|
||||||
set status = null
|
set status = null
|
||||||
where id = #{0}
|
where id = #{0}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -171,39 +171,9 @@
|
||||||
<if test="request.method != null">
|
<if test="request.method != null">
|
||||||
and test_case.method = #{request.method}
|
and test_case.method = #{request.method}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and test_case.version_id = #{request.versionId}
|
<property name="versionTable" value="test_case"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and test_case.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = test_case.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM test_case tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = test_case.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
and (test_case.status != 'Trash' or test_case.status is null)
|
and (test_case.status != 'Trash' or test_case.status is null)
|
||||||
<include refid="filter"/>
|
<include refid="filter"/>
|
||||||
</where>
|
</where>
|
||||||
|
@ -585,4 +555,16 @@
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -167,39 +167,9 @@
|
||||||
<if test="request.method != null">
|
<if test="request.method != null">
|
||||||
and test_case.method = #{request.method}
|
and test_case.method = #{request.method}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.versionId != null">
|
<include refid="queryVersionCondition">
|
||||||
and test_case.version_id = #{request.versionId}
|
<property name="versionTable" value="test_case"/>
|
||||||
</if>
|
</include>
|
||||||
<if test="request.refId != null">
|
|
||||||
and test_case.ref_id = #{request.refId}
|
|
||||||
</if>
|
|
||||||
<if test="request.versionId == null and request.refId == null and request.id == null">
|
|
||||||
AND (
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
|
|
||||||
WHERE ref_id = test_case.ref_id
|
|
||||||
LIMIT 1)
|
|
||||||
OR
|
|
||||||
version_id = (SELECT project_version.id
|
|
||||||
FROM test_case tmp
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp.project_id = project_version.project_id AND
|
|
||||||
tmp.version_id = project_version.id AND NOT EXISTS(SELECT ref_id
|
|
||||||
FROM test_case tmp2
|
|
||||||
JOIN project_version
|
|
||||||
ON tmp2.project_id =
|
|
||||||
project_version.project_id AND
|
|
||||||
version_id =
|
|
||||||
project_version.id AND
|
|
||||||
latest = TRUE
|
|
||||||
WHERE tmp.ref_id = tmp2.ref_id)
|
|
||||||
WHERE tmp.ref_id = test_case.ref_id
|
|
||||||
ORDER BY tmp.update_time DESC
|
|
||||||
LIMIT 1)
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<include refid="filter"/>
|
<include refid="filter"/>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
@ -492,4 +462,16 @@
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryVersionCondition">
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId == null and request.refId == null and request.id == null">
|
||||||
|
AND ${versionTable}.latest = 1
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
|
public class VersionConstants {
|
||||||
|
//最新版本
|
||||||
|
public static Byte LATEST = 1;
|
||||||
|
//非最新版本 可以不用设置数据库 default = 0
|
||||||
|
public static Byte NOT_LATEST = 0;
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.TestCaseConstants;
|
import io.metersphere.commons.constants.TestCaseConstants;
|
||||||
import io.metersphere.commons.constants.TestCaseReviewStatus;
|
import io.metersphere.commons.constants.TestCaseReviewStatus;
|
||||||
import io.metersphere.commons.constants.UserGroupType;
|
import io.metersphere.commons.constants.UserGroupType;
|
||||||
|
import io.metersphere.commons.constants.VersionConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
import io.metersphere.commons.user.SessionUser;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
|
@ -206,7 +207,8 @@ public class TestCaseService {
|
||||||
//从版本选择直接创建
|
//从版本选择直接创建
|
||||||
request.setRefId(request.getId());
|
request.setRefId(request.getId());
|
||||||
}
|
}
|
||||||
|
//完全新增一条记录直接就是最新
|
||||||
|
request.setLatest(VersionConstants.LATEST);
|
||||||
testCaseMapper.insert(request);
|
testCaseMapper.insert(request);
|
||||||
saveFollows(request.getId(), request.getFollows());
|
saveFollows(request.getId(), request.getFollows());
|
||||||
return request;
|
return request;
|
||||||
|
@ -306,9 +308,11 @@ public class TestCaseService {
|
||||||
testCase.setCreateUser(SessionUtils.getUserId());
|
testCase.setCreateUser(SessionUtils.getUserId());
|
||||||
testCase.setOrder(oldTestCase.getOrder());
|
testCase.setOrder(oldTestCase.getOrder());
|
||||||
testCase.setRefId(oldTestCase.getRefId());
|
testCase.setRefId(oldTestCase.getRefId());
|
||||||
|
testCase.setLatest(null);
|
||||||
DealWithOtherInfo(testCase, oldTestCase.getId());
|
DealWithOtherInfo(testCase, oldTestCase.getId());
|
||||||
testCaseMapper.insertSelective(testCase);
|
testCaseMapper.insertSelective(testCase);
|
||||||
}
|
}
|
||||||
|
checkAndSetLatestVersion(testCase.getRefId(), testCase.getVersionId(), testCase.getProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2490,6 +2494,30 @@ public class TestCaseService {
|
||||||
if (CollectionUtils.isNotEmpty(testCaseList)) {
|
if (CollectionUtils.isNotEmpty(testCaseList)) {
|
||||||
testCaseMapper.deleteByExample(e);
|
testCaseMapper.deleteByExample(e);
|
||||||
}
|
}
|
||||||
|
//检查最新版本
|
||||||
|
checkAndSetLatestVersion(refId, version, testCaseList.get(0).getProjectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查设置最新版本
|
||||||
|
*
|
||||||
|
* @param refId
|
||||||
|
* @param versionId
|
||||||
|
*/
|
||||||
|
private void checkAndSetLatestVersion(String refId, String versionId, String projectId) {
|
||||||
|
TestCaseExample e = new TestCaseExample();
|
||||||
|
e.createCriteria().andRefIdEqualTo(refId).andLatestEqualTo(VersionConstants.LATEST);
|
||||||
|
//如果因为删除导致没有了最新的版本,则按照版本创建顺序选择一个版本为最新版本
|
||||||
|
if (testCaseMapper.countByExample(e) == 0) {
|
||||||
|
extTestCaseMapper.addLatestVersion(refId);
|
||||||
|
} else {
|
||||||
|
//已经存在了最新版本 但是要判断这个所谓的最新版本是否是版本管理里面最新版本
|
||||||
|
String latestVersion = extProjectVersionMapper.getDefaultVersion(projectId);
|
||||||
|
if (StringUtils.equals(versionId, latestVersion)) {
|
||||||
|
extTestCaseMapper.clearLatestVersion(refId);
|
||||||
|
extTestCaseMapper.setLatestVersion(refId, versionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTestCasePublic(String versionId, String refId) {
|
public void deleteTestCasePublic(String versionId, String refId) {
|
||||||
|
|
|
@ -195,4 +195,56 @@ ALTER TABLE `test_plan_report_content` ADD COLUMN `error_report_cases` LONGTEXT
|
||||||
ALTER TABLE `test_plan_report_content` ADD COLUMN `error_report_scenarios` LONGTEXT COMMENT '误报状态场景用例';
|
ALTER TABLE `test_plan_report_content` ADD COLUMN `error_report_scenarios` LONGTEXT COMMENT '误报状态场景用例';
|
||||||
|
|
||||||
-- 缺陷相关配置
|
-- 缺陷相关配置
|
||||||
ALTER TABLE project ADD issue_config TEXT NULL;
|
ALTER TABLE project
|
||||||
|
ADD issue_config TEXT NULL;
|
||||||
|
|
||||||
|
-- 增加 latest 字段优化最新版本查询
|
||||||
|
|
||||||
|
ALTER TABLE test_case
|
||||||
|
ADD latest tinyint DEFAULT 0 COMMENT '是否为最新版本 0:否,1:是';
|
||||||
|
ALTER TABLE api_definition
|
||||||
|
ADD latest tinyint DEFAULT 0 COMMENT '是否为最新版本 0:否,1:是';
|
||||||
|
ALTER TABLE api_scenario
|
||||||
|
ADD latest tinyint DEFAULT 0 COMMENT '是否为最新版本 0:否,1:是';
|
||||||
|
ALTER TABLE load_test
|
||||||
|
ADD latest tinyint DEFAULT 0 COMMENT '是否为最新版本 0:否,1:是';
|
||||||
|
|
||||||
|
-- 设置最新版本的数据
|
||||||
|
|
||||||
|
UPDATE test_case
|
||||||
|
SET latest = 1
|
||||||
|
WHERE version_id = (
|
||||||
|
SELECT id
|
||||||
|
FROM project_version
|
||||||
|
WHERE project_version.project_id = test_case.project_id
|
||||||
|
AND project_version.latest = 1
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE api_definition
|
||||||
|
SET latest = 1
|
||||||
|
WHERE version_id = (
|
||||||
|
SELECT id
|
||||||
|
FROM project_version
|
||||||
|
WHERE project_version.project_id = api_definition.project_id
|
||||||
|
AND project_version.latest = 1
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE api_scenario
|
||||||
|
SET latest = 1
|
||||||
|
WHERE version_id = (
|
||||||
|
SELECT id
|
||||||
|
FROM project_version
|
||||||
|
WHERE project_version.project_id = api_scenario.project_id
|
||||||
|
AND project_version.latest = 1
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE load_test
|
||||||
|
SET latest = 1
|
||||||
|
WHERE version_id = (
|
||||||
|
SELECT id
|
||||||
|
FROM project_version
|
||||||
|
WHERE project_version.project_id = load_test.project_id
|
||||||
|
AND project_version.latest = 1
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
ref="versionHistory"
|
ref="versionHistory"
|
||||||
:version-data="versionData"
|
:version-data="versionData"
|
||||||
:current-id="currentTestCaseInfo.id"
|
:current-id="currentTestCaseInfo.id"
|
||||||
:is-test-case-version="true"
|
|
||||||
@confirmOtherInfo="confirmOtherInfo"
|
@confirmOtherInfo="confirmOtherInfo"
|
||||||
:current-project-id="currentProjectId"
|
:current-project-id="currentProjectId"
|
||||||
@compare="compare" @checkout="checkout" @create="create" @del="del"/>
|
@compare="compare" @checkout="checkout" @create="create" @del="del"/>
|
||||||
|
|
Loading…
Reference in New Issue