parent
ca95403adc
commit
dcdeae3982
|
@ -132,8 +132,10 @@ public class ApiDefinitionService {
|
||||||
request = this.initRequest(request, true, true);
|
request = this.initRequest(request, true, true);
|
||||||
List<ApiDefinitionResult> resList = extApiDefinitionMapper.list(request);
|
List<ApiDefinitionResult> resList = extApiDefinitionMapper.list(request);
|
||||||
buildUserInfo(resList);
|
buildUserInfo(resList);
|
||||||
|
if(StringUtils.isNotBlank(request.getProjectId())){
|
||||||
buildProjectInfo(resList, request.getProjectId());
|
buildProjectInfo(resList, request.getProjectId());
|
||||||
calculateResult(resList, request.getProjectId());
|
calculateResult(resList, request.getProjectId());
|
||||||
|
}
|
||||||
return resList;
|
return resList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@
|
||||||
left join project on api_definition.project_id = project.id
|
left join project on api_definition.project_id = project.id
|
||||||
left join user on api_definition.user_id = user.id
|
left join user on api_definition.user_id = user.id
|
||||||
left join user deleteUser on api_definition.delete_user_id = deleteUser.id
|
left join user deleteUser on api_definition.delete_user_id = deleteUser.id
|
||||||
<include refid="queryWhereCondition"/>
|
<include refid="queryWhereConditionWidthProject"/>
|
||||||
<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">
|
||||||
|
@ -683,6 +683,103 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="queryWhereCondition">
|
<sql id="queryWhereCondition">
|
||||||
|
<where>
|
||||||
|
<if test="request.combine != null">
|
||||||
|
<include refid="combine">
|
||||||
|
<property name="condition" value="request.combine"/>
|
||||||
|
<property name="name" value="request.name"/>
|
||||||
|
<property name="objectKey" value="request.combine.tags"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
<if test="request.name != null">
|
||||||
|
and (api_definition.name like CONCAT('%', #{request.name},'%')
|
||||||
|
or api_definition.tags like CONCAT('%', #{request.name},'%')
|
||||||
|
or api_definition.num like CONCAT('%', #{request.name},'%')
|
||||||
|
or api_definition.path like CONCAT('%', #{request.name},'%'))
|
||||||
|
</if>
|
||||||
|
<if test="request.protocol != null">
|
||||||
|
AND api_definition.protocol = #{request.protocol}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.notEqStatus != null">
|
||||||
|
and (api_definition.status is null or api_definition.status != #{request.notEqStatus})
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.id != null">
|
||||||
|
AND api_definition.id = #{request.id}
|
||||||
|
</if>
|
||||||
|
<if test="request.userId != null">
|
||||||
|
AND api_definition.user_id = #{request.userId}
|
||||||
|
</if>
|
||||||
|
<if test="request.createTime >0">
|
||||||
|
AND api_definition.create_time >= #{request.createTime}
|
||||||
|
</if>
|
||||||
|
<if test="request.moduleId != null">
|
||||||
|
AND api_definition.module_id = #{request.moduleId}
|
||||||
|
</if>
|
||||||
|
<if test="request.notInIds != null and request.notInIds.size() > 0">
|
||||||
|
and api_definition.id not in
|
||||||
|
<foreach collection="request.notInIds" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<choose>
|
||||||
|
<when test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||||
|
AND api_definition.module_id in
|
||||||
|
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||||
|
#{nodeId}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test="request.projectId != null">
|
||||||
|
AND api_definition.project_id = #{request.projectId}
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
<include refid="filter"/>
|
||||||
|
<if test="request.apiCaseCoverage == 'uncoverage' ">
|
||||||
|
and api_definition.id not in
|
||||||
|
(SELECT api_definition_id FROM api_test_case)
|
||||||
|
</if>
|
||||||
|
<if test="request.apiCaseCoverage == 'coverage' ">
|
||||||
|
and api_definition.id in
|
||||||
|
(SELECT api_definition_id FROM api_test_case)
|
||||||
|
</if>
|
||||||
|
<if test="request.refId != null">
|
||||||
|
AND ref_id = #{request.refId}
|
||||||
|
</if>
|
||||||
|
<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>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="queryWhereConditionWidthProject">
|
||||||
<where>
|
<where>
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
<include refid="combine">
|
<include refid="combine">
|
||||||
|
@ -782,7 +879,6 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectProjectIds" resultType="java.lang.String">
|
<select id="selectProjectIds" resultType="java.lang.String">
|
||||||
select DISTINCT project_id from api_definition;
|
select DISTINCT project_id from api_definition;
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -414,7 +414,7 @@
|
||||||
<select id="moduleCount" resultType="java.lang.Integer">
|
<select id="moduleCount" resultType="java.lang.Integer">
|
||||||
select count(test_case.id) from test_case
|
select count(test_case.id) from test_case
|
||||||
left join project on test_case.project_id = project.id
|
left join project on test_case.project_id = project.id
|
||||||
<include refid="queryWhereCondition"/>
|
<include refid="queryWhereConditionWidthProject"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="moduleCountByCollection" resultType="java.util.Map">
|
<select id="moduleCountByCollection" resultType="java.util.Map">
|
||||||
|
@ -433,7 +433,7 @@
|
||||||
<include refid="io.metersphere.base.mapper.TestCaseMapper.Base_Column_List"/>
|
<include refid="io.metersphere.base.mapper.TestCaseMapper.Base_Column_List"/>
|
||||||
</if>
|
</if>
|
||||||
from test_case left join project on test_case.project_id = project.id
|
from test_case left join project on test_case.project_id = project.id
|
||||||
<include refid="queryWhereCondition"/>
|
<include refid="queryWhereConditionWidthProject"/>
|
||||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
||||||
</select>
|
</select>
|
||||||
<select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO">
|
<select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO">
|
||||||
|
@ -570,6 +570,94 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="queryWhereCondition">
|
<sql id="queryWhereCondition">
|
||||||
|
<where>
|
||||||
|
<if test="request.combine != null">
|
||||||
|
<include refid="combine">
|
||||||
|
<property name="condition" value="request.combine"/>
|
||||||
|
<property name="name" value="request.name"/>
|
||||||
|
<property name="objectKey" value="request.combine.tags"/>
|
||||||
|
</include>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.statusIsNot != null">
|
||||||
|
and (test_case.status is null or test_case.status != #{request.statusIsNot})
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="request.notEqStatus != null">
|
||||||
|
and (test_case.status is null or test_case.status != #{request.notEqStatus})
|
||||||
|
</if>
|
||||||
|
<if test="request.name != null">
|
||||||
|
and (test_case.name like CONCAT('%', #{request.name},'%')
|
||||||
|
or test_case.num like CONCAT('%', #{request.name},'%')
|
||||||
|
or test_case.tags like CONCAT('%', #{request.name},'%')
|
||||||
|
or test_case.custom_num like CONCAT('%', #{request.name},'%'))
|
||||||
|
</if>
|
||||||
|
<if test="request.ids != null">
|
||||||
|
and test_case.id in
|
||||||
|
<foreach collection="request.ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="request.relevanceCreateTime >0">
|
||||||
|
and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >=
|
||||||
|
#{request.createTime})
|
||||||
|
</if>
|
||||||
|
<if test="request.createTime >0">
|
||||||
|
and test_case.create_time >= #{request.createTime}
|
||||||
|
</if>
|
||||||
|
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
|
||||||
|
and test_case.node_id in
|
||||||
|
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">
|
||||||
|
#{nodeId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="request.projectId != null">
|
||||||
|
and test_case.project_id = #{request.projectId}
|
||||||
|
</if>
|
||||||
|
<include refid="filters"/>
|
||||||
|
<if test="request.caseCoverage == 'uncoverage' ">
|
||||||
|
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)
|
||||||
|
</if>
|
||||||
|
<if test="request.caseCoverage == 'coverage' ">
|
||||||
|
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
|
||||||
|
</if>
|
||||||
|
<if test="request.versionId != null">
|
||||||
|
and test_case.version_id = #{request.versionId}
|
||||||
|
</if>
|
||||||
|
<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>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sql id="queryWhereConditionWidthProject">
|
||||||
<where>
|
<where>
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
<include refid="combine">
|
<include refid="combine">
|
||||||
|
|
|
@ -534,7 +534,9 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
List<TestCaseDTO> list = extTestCaseMapper.list(request);
|
List<TestCaseDTO> list = extTestCaseMapper.list(request);
|
||||||
buildUserInfo(list);
|
buildUserInfo(list);
|
||||||
|
if(StringUtils.isNotBlank(request.getProjectId())){
|
||||||
buildProjectInfo(request.getProjectId(), list);
|
buildProjectInfo(request.getProjectId(), list);
|
||||||
|
}
|
||||||
list = this.parseStatus(list);
|
list = this.parseStatus(list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue