diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 9151ab8652..e346e718f7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -132,8 +132,10 @@ public class ApiDefinitionService { request = this.initRequest(request, true, true); List resList = extApiDefinitionMapper.list(request); buildUserInfo(resList); - buildProjectInfo(resList, request.getProjectId()); - calculateResult(resList, request.getProjectId()); + if(StringUtils.isNotBlank(request.getProjectId())){ + buildProjectInfo(resList, request.getProjectId()); + calculateResult(resList, request.getProjectId()); + } return resList; } 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 019c8d5555..0bca0d0317 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 @@ -274,7 +274,7 @@ left join project on api_definition.project_id = project.id left join user on api_definition.user_id = user.id left join user deleteUser on api_definition.delete_user_id = deleteUser.id - + order by @@ -683,6 +683,103 @@ + + + + + + + + + + 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},'%')) + + + AND api_definition.protocol = #{request.protocol} + + + + and (api_definition.status is null or api_definition.status != #{request.notEqStatus}) + + + + AND api_definition.id = #{request.id} + + + AND api_definition.user_id = #{request.userId} + + + AND api_definition.create_time >= #{request.createTime} + + + AND api_definition.module_id = #{request.moduleId} + + + and api_definition.id not in + + #{id} + + + + + AND api_definition.module_id in + + #{nodeId} + + + + AND api_definition.project_id = #{request.projectId} + + + + + and api_definition.id not in + (SELECT api_definition_id FROM api_test_case) + + + and api_definition.id in + (SELECT api_definition_id FROM api_test_case) + + + AND ref_id = #{request.refId} + + + AND version_id = #{request.versionId} + + + 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) + ) + + + + + @@ -782,7 +879,6 @@ - diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 7cda738ebb..33b9215666 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -414,7 +414,7 @@