diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java
index 5a927d8c..d4e39a30 100644
--- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java
+++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java
@@ -122,4 +122,6 @@ public interface TypeMapper {
* @return 结果
*/
int logicDeleteTypeByTypeIds(Long[] typeIds);
+
+ Type queryByName(String typeName);
}
diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java
index ffe84b4c..c18d10f7 100644
--- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java
+++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java
@@ -246,6 +246,12 @@ public class TypeServiceImpl implements ITypeService {
*/
@Override
public int insertType(Type type) {
+ //根据类型名称判断,去重
+ Type maType = typeMapper.queryByName(type.getTypeName());
+ if (maType != null && maType.getParentId().equals(type.getParentId())) {
+ throw new RuntimeException("同级下类型名称存在重复!");
+ }
+ type.setLevel(String.valueOf(Integer.parseInt(type.getLevel()) + 1));
type.setCreateTime(DateUtils.getNowDate());
type.setCreateBy(SecurityUtils.getUserId().toString());
return typeMapper.insertType(type);
diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml
index ecc947fa..36de8699 100644
--- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml
+++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml
@@ -435,9 +435,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and m2.del_flag = '0'
LEFT JOIN ma_type m3 ON m2.parent_id = m3.type_id
and m3.del_flag = '0'
- WHERE m.parent_id = #{typeId} and m.status = '0' and m.del_flag = '0'
+ WHERE m.parent_id = #{typeId} and m.del_flag = '0'
AND m.type_name like concat('%',#{typeName},'%')
+
\ No newline at end of file