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 fb94f2353f..674dd17377 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -272,17 +272,13 @@ public class ApiModuleService extends NodeTreeService { ApiModuleExample example = new ApiModuleExample(); ApiModuleExample.Criteria criteria = example.createCriteria(); criteria.andNameEqualTo(node.getName()) - .andProjectIdEqualTo(node.getProjectId()); + .andProjectIdEqualTo(node.getProjectId()) + .andLevelEqualTo(node.getLevel()); if (StringUtils.isNotBlank(node.getProtocol())) { criteria.andProtocolEqualTo(node.getProtocol()); } - if (StringUtils.isNotBlank(node.getParentId())) { - criteria.andParentIdEqualTo(node.getParentId()); - } else { - criteria.andParentIdIsNull(); - } if (StringUtils.isNotBlank(node.getId())) { criteria.andIdNotEqualTo(node.getId()); } @@ -296,12 +292,9 @@ public class ApiModuleService extends NodeTreeService { ApiModuleExample example = new ApiModuleExample(); ApiModuleExample.Criteria criteria = example.createCriteria(); criteria.andNameEqualTo(node.getName()) - .andProjectIdEqualTo(node.getProjectId()); - if (StringUtils.isNotBlank(node.getParentId())) { - criteria.andParentIdEqualTo(node.getParentId()); - } else { - criteria.andParentIdIsNull(); - } + .andProjectIdEqualTo(node.getProjectId()) + .andLevelEqualTo(node.getLevel()); + if (StringUtils.isNotBlank(node.getId())) { criteria.andIdNotEqualTo(node.getId()); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index 208d1cc11d..6ba7929973 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -233,12 +233,9 @@ public class ApiScenarioModuleService extends NodeTreeService { TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample.Criteria criteria = example.createCriteria(); criteria.andNameEqualTo(node.getName()) - .andProjectIdEqualTo(node.getProjectId()); - if (StringUtils.isNotBlank(node.getParentId())) { - criteria.andParentIdEqualTo(node.getParentId()); - } else { - criteria.andParentIdIsNull(); - } + .andProjectIdEqualTo(node.getProjectId()) + .andLevelEqualTo(node.getLevel()); + if (StringUtils.isNotBlank(node.getId())) { criteria.andIdNotEqualTo(node.getId()); } @@ -575,12 +572,9 @@ public class BaseModuleService extends NodeTreeService { TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample.Criteria criteria = example.createCriteria(); criteria.andNameEqualTo(node.getName()) - .andProjectIdEqualTo(node.getProjectId()); - if (StringUtils.isNotBlank(node.getParentId())) { - criteria.andParentIdEqualTo(node.getParentId()); - } else { - criteria.andParentIdIsNull(); - } + .andProjectIdEqualTo(node.getProjectId()) + .andLevelEqualTo(node.getLevel()); + if (StringUtils.isNotBlank(node.getId())) { criteria.andIdNotEqualTo(node.getId()); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index 0483f54306..b87338afab 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -104,12 +104,9 @@ public class TestCaseNodeService extends NodeTreeService { TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample.Criteria criteria = example.createCriteria(); criteria.andNameEqualTo(node.getName()) - .andProjectIdEqualTo(node.getProjectId()); - if (StringUtils.isNotBlank(node.getParentId())) { - criteria.andParentIdEqualTo(node.getParentId()); - } else { - criteria.andParentIdIsNull(); - } + .andProjectIdEqualTo(node.getProjectId()) + .andLevelEqualTo(node.getLevel()); + if (StringUtils.isNotBlank(node.getId())) { criteria.andIdNotEqualTo(node.getId()); } @@ -658,12 +655,10 @@ public class TestCaseNodeService extends NodeTreeService { if (module == null && StringUtils.isNotEmpty(node.getName())) { TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample.Criteria criteria = example.createCriteria(); - criteria.andNameEqualTo(node.getName()).andProjectIdEqualTo(node.getProjectId()); - if (StringUtils.isNotEmpty(node.getParentId())) { - criteria.andParentIdEqualTo(node.getParentId()); - } else { - criteria.andParentIdIsNull(); - } + criteria.andNameEqualTo(node.getName()). + andProjectIdEqualTo(node.getProjectId()) + .andLevelEqualTo(node.getLevel()); + if (StringUtils.isNotEmpty(node.getId())) { criteria.andIdNotEqualTo(node.getId()); }