|
|
@@ -3,6 +3,7 @@ package com.sckw.system.service;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.base.BaseModel;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
@@ -47,15 +48,22 @@ public class SysDictFlexBusinessService {
|
|
|
|
|
|
// 业务校验:检查是否存在相同的字典项
|
|
|
SysDict existDict = sysDictRepository.selectUniqueDict(
|
|
|
- entity.getDictId(),
|
|
|
- entity.getValue(),
|
|
|
+ entity.getDictId(),
|
|
|
entity.getLabel(),
|
|
|
entity.getType(),
|
|
|
entity.getParentId()
|
|
|
);
|
|
|
if (existDict != null) {
|
|
|
- log.error("字典项已存在,请勿重复添加");
|
|
|
- return Boolean.FALSE;
|
|
|
+ // return Boolean.FALSE;
|
|
|
+ if (StringUtils.equals(entity.getLabel(), existDict.getLabel())){
|
|
|
+ log.error("字典名称已存在,请勿重复添加");
|
|
|
+ throw new BusinessException("字典名称已存在,请勿重复添加");
|
|
|
+ }
|
|
|
+ if (StringUtils.equals(entity.getValue(), existDict.getValue())) {
|
|
|
+ log.error("字典项值已存在,请勿重复添加");
|
|
|
+ throw new BusinessException("字典项值已存在,请勿重复添加");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 设置创建信息
|
|
|
@@ -111,6 +119,12 @@ public class SysDictFlexBusinessService {
|
|
|
// 设置更新信息
|
|
|
Long userId = LoginUserHolder.getUserId();
|
|
|
SysDict sysDict = new SysDict();
|
|
|
+ sysDict.setDictId(entity.getDictId());
|
|
|
+ sysDict.setValue(entity.getValue());
|
|
|
+ sysDict.setLabel(entity.getLabel());
|
|
|
+ sysDict.setType(entity.getType());
|
|
|
+ sysDict.setDescription(entity.getDescription());
|
|
|
+ sysDict.setParentId(entity.getParentId());
|
|
|
sysDict.setId(existDict.getId());
|
|
|
sysDict.setSort(entity.getSort());
|
|
|
sysDict.setRemark(entity.getRemark());
|