提交 feeebf72 编写于 作者: C chenjianxing

fix: 模块重名校验

上级 1f94c618
......@@ -45,11 +45,7 @@ public class TestCaseNodeService {
SqlSessionFactory sqlSessionFactory;
public String addNode(TestCaseNode node) {
if(node.getLevel() > TestCaseConstants.MAX_NODE_DEPTH){
throw new RuntimeException(Translator.get("test_case_node_level_tip")
+ TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"));
}
validateNode(node);
node.setCreateTime(System.currentTimeMillis());
node.setUpdateTime(System.currentTimeMillis());
node.setId(UUID.randomUUID().toString());
......@@ -57,6 +53,34 @@ public class TestCaseNodeService {
return node.getId();
}
private void validateNode(TestCaseNode node) {
if(node.getLevel() > TestCaseConstants.MAX_NODE_DEPTH){
throw new RuntimeException(Translator.get("test_case_node_level_tip")
+ TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"));
}
checkTestCaseNodeExist(node);
}
private void checkTestCaseNodeExist(TestCaseNode node) {
if (node.getName() != null) {
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();
}
if (StringUtils.isNotBlank(node.getId())) {
criteria.andIdNotEqualTo(node.getId());
}
if (testCaseNodeMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("test_case_module_already_exists"));
}
}
}
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId) {
TestCaseNodeExample testCaseNodeExample = new TestCaseNodeExample();
testCaseNodeExample.createCriteria().andProjectIdEqualTo(projectId);
......@@ -119,7 +143,7 @@ public class TestCaseNodeService {
public int editNode(DragNodeRequest request) {
request.setUpdateTime(System.currentTimeMillis());
checkTestCaseNodeExist(request);
List<TestCaseDTO> testCases = QueryTestCaseByNodeIds(request.getNodeIds());
testCases.forEach(testCase -> {
......@@ -376,7 +400,7 @@ public class TestCaseNodeService {
public void dragNode(DragNodeRequest request) {
// editNode(request);
checkTestCaseNodeExist(request);
List<String> nodeIds = request.getNodeIds();
......
......@@ -73,14 +73,7 @@ public class TestCaseService {
public void addTestCase(TestCaseWithBLOBs testCase) {
testCase.setName(testCase.getName());
TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria()
.andProjectIdEqualTo(testCase.getProjectId())
.andNameEqualTo(testCase.getName());
List<TestCase> testCases = testCaseMapper.selectByExample(testCaseExample);
if (testCases.size() > 0) {
MSException.throwException(Translator.get("test_case_exist") + testCase.getName());
}
checkTestCaseExist(testCase);
testCase.setId(UUID.randomUUID().toString());
testCase.setCreateTime(System.currentTimeMillis());
testCase.setUpdateTime(System.currentTimeMillis());
......@@ -107,10 +100,12 @@ public class TestCaseService {
private void checkTestCaseExist(TestCaseWithBLOBs testCase) {
if (testCase.getName() != null) {
TestCaseExample example = new TestCaseExample();
example.createCriteria()
.andNameEqualTo(testCase.getName())
.andProjectIdEqualTo(testCase.getProjectId())
.andIdNotEqualTo(testCase.getId());
TestCaseExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(testCase.getName())
.andProjectIdEqualTo(testCase.getProjectId());
if (StringUtils.isNotBlank(testCase.getId())) {
criteria.andIdNotEqualTo(testCase.getId());
}
if (testCaseMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("test_case_already_exists"));
}
......
......@@ -115,6 +115,7 @@ please_input_workspace_member=Please input workspace merber
test_case_report_template_repeat=The workspace has the same name template
plan_name_already_exists=Test plan name already exists
test_case_already_exists_excel=There are duplicate test cases in the import file
test_case_module_already_exists=The module name already exists at the same level
api_test_name_already_exists=Test name already exists
#ldap
......
......@@ -115,6 +115,7 @@ please_input_workspace_member=请填写该工作空间相关人员
test_case_report_template_repeat=同一工作空间下不能存在同名模版
plan_name_already_exists=测试计划名称已存在
test_case_already_exists_excel=导入文件中存在重复用例
test_case_module_already_exists=同层级下已存在该模块名称
api_test_name_already_exists=测试名称已经存在
#ldap
......
......@@ -115,6 +115,7 @@ please_input_workspace_member=請填寫該工作空間相關人員
test_case_report_template_repeat=同壹工作空間下不能存在同名模版
plan_name_already_exists=測試計劃名稱已存在
test_case_already_exists_excel=導入文件中存在重復用例
test_case_module_already_exists=同層級下已存在該模塊名稱
api_test_name_already_exists=測試名稱已經存在
#ldap
......
......@@ -109,6 +109,8 @@ export default {
handleDragEnd(draggingNode, dropNode, dropType, ev) {
let param = {};
param.id = draggingNode.data.id;
param.name = draggingNode.data.name;
param.projectId = draggingNode.data.projectId;
if (dropType === "inner") {
param.parentId = dropNode.data.id;
param.level = dropNode.data.level + 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册