refactor: 测试用例模块树加载优化
This commit is contained in:
parent
6c329d3f1e
commit
8f43deaf41
|
@ -93,16 +93,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
moduleIds = this.nodeList(apiModules, node.getId(), moduleIds);
|
||||
moduleIds.add(node.getId());
|
||||
request.setModuleIds(moduleIds);
|
||||
int num = this.getCaseNum(request);
|
||||
node.setCaseNum(num);
|
||||
node.setCaseNum(extApiDefinitionMapper.moduleCount(request));
|
||||
});
|
||||
return getNodeTrees(apiModules);
|
||||
}
|
||||
|
||||
private int getCaseNum(ApiDefinitionRequest request) {
|
||||
return extApiDefinitionMapper.list(request).size();
|
||||
}
|
||||
|
||||
public static List<String> nodeList(List<ApiModuleDTO> apiNodes, String pid, List<String> list) {
|
||||
for (ApiModuleDTO node : apiNodes) {
|
||||
//遍历出父id等于参数的id,add进子节点集合
|
||||
|
|
|
@ -17,6 +17,8 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
List<ApiDefinitionResult> list(@Param("request") ApiDefinitionRequest request);
|
||||
|
||||
int moduleCount(@Param("request") ApiDefinitionRequest request);
|
||||
|
||||
//List<ApiComputeResult> selectByIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<ApiComputeResult> selectByIds(@Param("ids") List<String> ids, @Param("projectId") String projectId);
|
||||
|
|
|
@ -487,50 +487,12 @@
|
|||
WHERE project_id = #{0} AND status != 'Trash' AND protocol = 'HTTP'
|
||||
</select>
|
||||
|
||||
<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},'%'))
|
||||
</if>
|
||||
<if test="request.protocol != null">
|
||||
AND api_definition.protocol = #{request.protocol}
|
||||
</if>
|
||||
<if test="request.workspaceId != null">
|
||||
AND project.workspace_id = #{request.workspaceId}
|
||||
</if>
|
||||
<if test="request.projectId != null">
|
||||
AND project.id = #{request.projectId}
|
||||
</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.projectId != null">
|
||||
AND api_definition.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if 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>
|
||||
</if>
|
||||
<select id="moduleCount" resultType="java.lang.Integer">
|
||||
select count(id) from api_definition
|
||||
<include refid="queryWhereCondition"/>
|
||||
</select>
|
||||
|
||||
<sql id="filter">
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
|
@ -557,6 +519,55 @@
|
|||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<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},'%'))
|
||||
</if>
|
||||
<if test="request.protocol != null">
|
||||
AND api_definition.protocol = #{request.protocol}
|
||||
</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>
|
||||
<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>
|
||||
<when test="request.projectId != null">
|
||||
AND project.id = #{request.projectId}
|
||||
</when>
|
||||
<when test="request.workspaceId != null">
|
||||
AND project.workspace_id = #{request.workspaceId}
|
||||
</when>
|
||||
</choose>
|
||||
<include refid="filter"/>
|
||||
<if test="request.apiCaseCoverage == 'uncoverage' ">
|
||||
and api_definition.id not in
|
||||
(SELECT api_definition_id FROM api_test_case)
|
||||
|
@ -565,8 +576,6 @@
|
|||
and api_definition.id in
|
||||
(SELECT api_definition_id FROM api_test_case)
|
||||
</if>
|
||||
|
||||
|
||||
</where>
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in New Issue