feat: 修复校验字典code不准确问题
This commit is contained in:
@@ -35,6 +35,15 @@ public interface DictMapper extends BaseMapper<Dict> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DictVO> getAllDictWithData();
|
List<DictVO> getAllDictWithData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定字典编码对应的的数量
|
||||||
|
*
|
||||||
|
* @param dictCode 字典编码
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long getDictCodeCount(String dictCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,9 +67,8 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
|||||||
// 校验 code 是否唯一
|
// 校验 code 是否唯一
|
||||||
String dictCode = entity.getDictCode();
|
String dictCode = entity.getDictCode();
|
||||||
|
|
||||||
long count = this.count(new LambdaQueryWrapper<Dict>()
|
long count = this.baseMapper.getDictCodeCount(dictCode);
|
||||||
.eq(Dict::getDictCode, dictCode)
|
|
||||||
);
|
|
||||||
Assert.isTrue(count == 0, "字典编码已存在");
|
Assert.isTrue(count == 0, "字典编码已存在");
|
||||||
|
|
||||||
return this.save(entity);
|
return this.save(entity);
|
||||||
|
|||||||
@@ -47,4 +47,14 @@
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
t1.create_time DESC
|
t1.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 获取指定字典编码对应的的数量 -->
|
||||||
|
<select id="getDictCodeCount" resultType="java.lang.Long">
|
||||||
|
SELECT
|
||||||
|
COUNT(*) AS total
|
||||||
|
FROM
|
||||||
|
sys_dict
|
||||||
|
WHERE
|
||||||
|
dict_code = #{dictCode}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user