fix(测试跟踪): 创建项目时测试跟踪默认模块重复创建的问题
--bug=1018836 --user=宋昌昌 【测试跟踪】功能用例列表中出现两个未规划模块(只有俩项目出现) https://www.tapd.cn/55049933/s/1276852
This commit is contained in:
parent
e9527bf39a
commit
d35e1eb4e4
|
@ -159,7 +159,6 @@
|
|||
distinct
|
||||
</if>
|
||||
<include refid="io.metersphere.base.mapper.TestCaseNodeMapper.Base_Column_List"/>
|
||||
,module_path
|
||||
from ${tableName}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.listener;
|
||||
|
||||
import io.metersphere.base.domain.ModuleNode;
|
||||
import io.metersphere.base.domain.TestCaseNodeExample;
|
||||
import io.metersphere.base.mapper.ext.ExtModuleNodeMapper;
|
||||
import io.metersphere.commons.constants.KafkaTopicConstants;
|
||||
import io.metersphere.commons.constants.ProjectModuleDefaultNodeEnum;
|
||||
|
@ -11,6 +12,7 @@ import org.springframework.kafka.annotation.KafkaListener;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
|
@ -28,6 +30,12 @@ public class ProjectCreatedListener {
|
|||
}
|
||||
|
||||
private void initProjectDefaultNode(String projectId) {
|
||||
// 防止重复创建功能用例默认节点
|
||||
TestCaseNodeExample example = new TestCaseNodeExample();
|
||||
example.createCriteria()
|
||||
.andProjectIdEqualTo(projectId).andNameEqualTo(ProjectModuleDefaultNodeEnum.TEST_CASE_DEFAULT_NODE.getNodeName());
|
||||
List<ModuleNode> moduleNodes = extModuleNodeMapper.selectByExample(ProjectModuleDefaultNodeEnum.TEST_CASE_DEFAULT_NODE.getTableName(), example);
|
||||
if (moduleNodes.size() == 0) {
|
||||
ModuleNode record = new ModuleNode();
|
||||
record.setId(UUID.randomUUID().toString());
|
||||
record.setCreateUser(SessionUtils.getUserId());
|
||||
|
@ -39,4 +47,5 @@ public class ProjectCreatedListener {
|
|||
record.setName(ProjectModuleDefaultNodeEnum.TEST_CASE_DEFAULT_NODE.getNodeName());
|
||||
extModuleNodeMapper.insert(ProjectModuleDefaultNodeEnum.TEST_CASE_DEFAULT_NODE.getTableName(), record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue