Explorar el Código

添加字典名称校验

wyyay hace 2 años
padre
commit
6a306e53d6

+ 8 - 0
base-system/src/main/java/com/ozs/system/mapper/SysDictTypeMapper.java

@@ -84,4 +84,12 @@ public interface SysDictTypeMapper extends JoinBaseMapper<SysDictType> {
      * @return 结果
      */
     public SysDictType checkDictTypeUnique(String dictType);
+
+    /**
+     * 校验字典名称是否唯一
+     *
+     * @param dictName 字典名称
+     * @return 结果
+     */
+    public SysDictType checkDictNameUnique(String dictName);
 }

+ 7 - 0
base-system/src/main/java/com/ozs/system/service/ISysDictTypeService.java

@@ -96,4 +96,11 @@ public interface ISysDictTypeService extends JoinIService<SysDictType> {
      * @return 结果
      */
     public String checkDictTypeUnique(SysDictType dictType);
+    /**
+     * 校验字典名称是否唯一
+     *
+     * @param dictName 字典名称
+     * @return 结果
+     */
+    public String checkDictNameUnique(SysDictType dictName);
 }

+ 16 - 0
base-system/src/main/java/com/ozs/system/service/impl/SysDictTypeServiceImpl.java

@@ -200,4 +200,20 @@ public class SysDictTypeServiceImpl extends JoinServiceImpl<SysDictTypeMapper, S
         }
         return UserConstants.UNIQUE;
     }
+
+    /**
+     * 校验字典名称是否唯一
+     *
+     * @param dict 字典名称
+     * @return 结果
+     */
+    @Override
+    public String checkDictNameUnique(SysDictType dict) {
+        Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
+        SysDictType dictType = dictTypeMapper.checkDictNameUnique(dict.getDictName());
+        if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
 }

+ 5 - 0
base-system/src/main/resources/mapper/system/SysDictTypeMapper.xml

@@ -66,6 +66,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where dict_type = #{dictType} limit 1
 	</select>
 
+	<select id="checkDictNameUnique" parameterType="String" resultMap="SysDictTypeResult">
+		<include refid="selectDictTypeVo"/>
+		where dict_name = #{dictName} limit 1
+	</select>
+
 	<delete id="deleteDictTypeById" parameterType="Long">
  		delete from sys_dict_type where dict_id = #{dictId}
  	</delete>