|
|
@@ -16,7 +16,10 @@
|
|
|
*/
|
|
|
package org.springblade.modules.system.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.exceptions.ApiException;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
@@ -25,6 +28,7 @@ import org.springblade.modules.system.entity.Dict;
|
|
|
import org.springblade.modules.system.mapper.DictMapper;
|
|
|
import org.springblade.modules.system.service.IDictService;
|
|
|
import org.springblade.modules.system.vo.DictVO;
|
|
|
+import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -55,8 +59,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
|
|
|
@Override
|
|
|
@Cacheable(cacheNames = DICT_VALUE, key = "#code+'_'+#dictKey")
|
|
|
public String getValue(String code, Integer dictKey) {
|
|
|
- String value = Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY);
|
|
|
- return value;
|
|
|
+ return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -65,4 +68,15 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
|
|
|
return baseMapper.getList(code);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE})
|
|
|
+ public boolean submit(Dict dict) {
|
|
|
+ LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey());
|
|
|
+ Integer cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId()));
|
|
|
+ if (cnt > 0) {
|
|
|
+ throw new ApiException("当前字典键值已存在!");
|
|
|
+ }
|
|
|
+ return saveOrUpdate(dict);
|
|
|
+ }
|
|
|
+
|
|
|
}
|