diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index 09e88479e8..a227616dc8 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -93,16 +93,11 @@ public class ApiModuleService extends NodeTreeService { 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 nodeList(List apiNodes, String pid, List list) { for (ApiModuleDTO node : apiNodes) { //遍历出父id等于参数的id,add进子节点集合 diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index 37f919f171..bc48afd234 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -17,6 +17,8 @@ public interface ExtApiDefinitionMapper { List list(@Param("request") ApiDefinitionRequest request); + int moduleCount(@Param("request") ApiDefinitionRequest request); + //List selectByIds(@Param("ids") List ids); List selectByIds(@Param("ids") List ids, @Param("projectId") String projectId); @@ -46,4 +48,4 @@ public interface ExtApiDefinitionMapper { List selectEffectiveIdByProjectId(String projectId); List listByIds(@Param("ids") List ids); -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 76f2f11a2a..bdda804945 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -487,6 +487,40 @@ WHERE project_id = #{0} AND status != 'Trash' AND protocol = 'HTTP' + + + + + + + + + and api_definition.status in + + #{value} + + + + and api_definition.method in + + #{value} + + + + and api_definition.user_id in + + #{value} + + + + + + + + @@ -504,12 +538,6 @@ AND api_definition.protocol = #{request.protocol} - - AND project.workspace_id = #{request.workspaceId} - - - AND project.id = #{request.projectId} - AND api_definition.id = #{request.id} @@ -522,41 +550,24 @@ AND api_definition.module_id = #{request.moduleId} - - AND api_definition.project_id = #{request.projectId} - - - AND api_definition.module_id in - - #{nodeId} - - - - - - - - and api_definition.status in - - #{value} - - - - and api_definition.method in - - #{value} - - - - and api_definition.user_id in - - #{value} - - - - - - + + + AND api_definition.module_id in + + #{nodeId} + + + + AND api_definition.project_id = #{request.projectId} + + + AND project.id = #{request.projectId} + + + AND project.workspace_id = #{request.workspaceId} + + + 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) - - - \ No newline at end of file +