fix: 添加模块重名校验失效

This commit is contained in:
chenjianxing 2022-04-24 17:42:48 +08:00 committed by John Bro
parent 268ac8cc74
commit a87f3a20ca
4 changed files with 24 additions and 48 deletions

View File

@ -272,17 +272,13 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
ApiModuleExample example = new ApiModuleExample(); ApiModuleExample example = new ApiModuleExample();
ApiModuleExample.Criteria criteria = example.createCriteria(); ApiModuleExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
.andLevelEqualTo(node.getLevel());
if (StringUtils.isNotBlank(node.getProtocol())) { if (StringUtils.isNotBlank(node.getProtocol())) {
criteria.andProtocolEqualTo(node.getProtocol()); criteria.andProtocolEqualTo(node.getProtocol());
} }
if (StringUtils.isNotBlank(node.getParentId())) {
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }
@ -296,12 +292,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
ApiModuleExample example = new ApiModuleExample(); ApiModuleExample example = new ApiModuleExample();
ApiModuleExample.Criteria criteria = example.createCriteria(); ApiModuleExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
if (StringUtils.isNotBlank(node.getParentId())) { .andLevelEqualTo(node.getLevel());
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }

View File

@ -233,12 +233,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
ApiScenarioModuleExample example = new ApiScenarioModuleExample(); ApiScenarioModuleExample example = new ApiScenarioModuleExample();
ApiScenarioModuleExample.Criteria criteria = example.createCriteria(); ApiScenarioModuleExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
if (StringUtils.isNotBlank(node.getParentId())) { .andLevelEqualTo(node.getLevel());
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }
@ -321,12 +318,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
ApiScenarioModuleExample example = new ApiScenarioModuleExample(); ApiScenarioModuleExample example = new ApiScenarioModuleExample();
ApiScenarioModuleExample.Criteria criteria = example.createCriteria(); ApiScenarioModuleExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
if (StringUtils.isNotBlank(node.getParentId())) { .andLevelEqualTo(node.getLevel());
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }

View File

@ -93,12 +93,9 @@ public class BaseModuleService extends NodeTreeService<ModuleNodeDTO> {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
TestCaseNodeExample.Criteria criteria = example.createCriteria(); TestCaseNodeExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
if (StringUtils.isNotBlank(node.getParentId())) { .andLevelEqualTo(node.getLevel());
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }
@ -575,12 +572,9 @@ public class BaseModuleService extends NodeTreeService<ModuleNodeDTO> {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
TestCaseNodeExample.Criteria criteria = example.createCriteria(); TestCaseNodeExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
if (StringUtils.isNotBlank(node.getParentId())) { .andLevelEqualTo(node.getLevel());
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }

View File

@ -104,12 +104,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
TestCaseNodeExample.Criteria criteria = example.createCriteria(); TestCaseNodeExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()) criteria.andNameEqualTo(node.getName())
.andProjectIdEqualTo(node.getProjectId()); .andProjectIdEqualTo(node.getProjectId())
if (StringUtils.isNotBlank(node.getParentId())) { .andLevelEqualTo(node.getLevel());
criteria.andParentIdEqualTo(node.getParentId());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotBlank(node.getId())) { if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }
@ -658,12 +655,10 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
if (module == null && StringUtils.isNotEmpty(node.getName())) { if (module == null && StringUtils.isNotEmpty(node.getName())) {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
TestCaseNodeExample.Criteria criteria = example.createCriteria(); TestCaseNodeExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(node.getName()).andProjectIdEqualTo(node.getProjectId()); criteria.andNameEqualTo(node.getName()).
if (StringUtils.isNotEmpty(node.getParentId())) { andProjectIdEqualTo(node.getProjectId())
criteria.andParentIdEqualTo(node.getParentId()); .andLevelEqualTo(node.getLevel());
} else {
criteria.andParentIdIsNull();
}
if (StringUtils.isNotEmpty(node.getId())) { if (StringUtils.isNotEmpty(node.getId())) {
criteria.andIdNotEqualTo(node.getId()); criteria.andIdNotEqualTo(node.getId());
} }