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);
|
||||
|
@ -46,4 +48,4 @@ public interface ExtApiDefinitionMapper {
|
|||
List<ApiDefinition> selectEffectiveIdByProjectId(String projectId);
|
||||
|
||||
List<ApiDefinitionResult> listByIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -487,6 +487,40 @@
|
|||
WHERE project_id = #{0} AND status != 'Trash' AND protocol = 'HTTP'
|
||||
</select>
|
||||
|
||||
<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">
|
||||
<choose>
|
||||
<when test="key=='status'">
|
||||
and api_definition.status in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='method'">
|
||||
and api_definition.method in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='user_id'">
|
||||
and api_definition.user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<sql id="queryWhereCondition">
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
|
@ -504,12 +538,6 @@
|
|||
<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>
|
||||
|
@ -522,41 +550,24 @@
|
|||
<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>
|
||||
<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">
|
||||
<choose>
|
||||
<when test="key=='status'">
|
||||
and api_definition.status in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='method'">
|
||||
and api_definition.method in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='user_id'">
|
||||
and api_definition.user_id in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</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>
|
||||
<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>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue