|
@@ -25,6 +25,7 @@ import lombok.AllArgsConstructor;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.springblade.control.entity.UserContractInfo;
|
|
|
+import org.springblade.control.mapper.DictInfoMapper;
|
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
@@ -48,6 +49,7 @@ import org.springblade.control.service.IDictInfoService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -70,6 +72,8 @@ public class DictInfoController extends BladeController {
|
|
|
|
|
|
private final IDictInfoService dictInfoService;
|
|
|
|
|
|
+ private final DictInfoMapper dictInfoMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 新增或修改 参数信息表
|
|
|
*/
|
|
@@ -77,22 +81,47 @@ public class DictInfoController extends BladeController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入dictInfo")
|
|
|
public R submit(@Valid @RequestBody DictInfo dictInfo) {
|
|
|
-
|
|
|
+ List<DictInfo> list = new ArrayList<>();
|
|
|
if (ObjectUtil.isNotEmpty(dictInfo.getId())) {
|
|
|
DictInfo dictInfo1 = dictInfoService.getBaseMapper().selectById(dictInfo.getId());
|
|
|
if (dictInfo1 != null && dictInfo1.getType().equals(6)) {
|
|
|
throw new ServiceException("没有权限,请联系管理员");
|
|
|
}
|
|
|
+ list = dictInfoService.list(new LambdaQueryWrapper<DictInfo>()
|
|
|
+ .eq(DictInfo::getParentId,dictInfo.getParentId() == null ? 0 : dictInfo.getParentId())
|
|
|
+ .eq(DictInfo::getType,dictInfo.getType())
|
|
|
+ .ne(DictInfo::getId,dictInfo.getId()));
|
|
|
+ //存在id,校验是否已经被引用过,目前只校验成本测算
|
|
|
+ if (dictInfo.getType() == 5) {
|
|
|
+ Integer linkTotal = dictInfoMapper.getLinkTotal(dictInfo1);
|
|
|
+ if (linkTotal > 0){
|
|
|
+ return R.fail("编辑失败,当前字典已经被引用过");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ list = dictInfoService.list(new LambdaQueryWrapper<DictInfo>()
|
|
|
+ .eq(DictInfo::getParentId,dictInfo.getParentId() == null ? 0 : dictInfo.getParentId())
|
|
|
+ .eq(DictInfo::getType,dictInfo.getType()));
|
|
|
+ }
|
|
|
+ //校验科目值是否与同等级重复
|
|
|
+ if (dictInfo.getType() == 5) {
|
|
|
+ for (DictInfo info : list) {
|
|
|
+ if (info.getDictValue().equals(dictInfo.getDictValue())) {
|
|
|
+ return R.fail("编辑失败,字典值与其他科目重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- DictInfo dictInfoOne = dictInfoService.getOne(new LambdaQueryWrapper<DictInfo>()
|
|
|
- .eq(DictInfo::getDictName, dictInfo.getDictName())
|
|
|
- .eq(DictInfo::getType, dictInfo.getType())
|
|
|
- .eq(DictInfo::getIsDeleted, 0));
|
|
|
+// DictInfo dictInfoOne = dictInfoService.getOne(new LambdaQueryWrapper<DictInfo>()
|
|
|
+// .eq(DictInfo::getDictName, dictInfo.getDictName())
|
|
|
+// .eq(DictInfo::getType, dictInfo.getType())
|
|
|
+// .eq(DictInfo::getIsDeleted, 0));
|
|
|
+//
|
|
|
+// if(dictInfoOne !=null && StringUtil.isNotBlank(dictInfoOne.getId()+"")) {
|
|
|
+// dictInfoOne.setId(dictInfoOne.getId());
|
|
|
+// }
|
|
|
|
|
|
- if(dictInfoOne !=null && StringUtil.isNotBlank(dictInfoOne.getId()+"")) {
|
|
|
- dictInfoOne.setId(dictInfoOne.getId());
|
|
|
- }
|
|
|
+ //判断是新增
|
|
|
|
|
|
CacheUtil.clear(DICT_CACHE, Boolean.FALSE);
|
|
|
return R.status(dictInfoService.saveOrUpdate(dictInfo));
|
|
@@ -111,6 +140,13 @@ public class DictInfoController extends BladeController {
|
|
|
if (dictInfo1 != null && dictInfo1.getType().equals(6)) {
|
|
|
throw new ServiceException("没有权限,请联系管理员");
|
|
|
}
|
|
|
+ if (dictInfo1.getType() == 5) {
|
|
|
+ //成本测算校验是否被引用过
|
|
|
+ Integer linkTotal = dictInfoMapper.getLinkTotal(dictInfo1);
|
|
|
+ if (linkTotal > 0) {
|
|
|
+ return R.fail("删除失败,当前字典已经被引用过");
|
|
|
+ }
|
|
|
+ }
|
|
|
CacheUtil.clear(DICT_CACHE, Boolean.FALSE);
|
|
|
return R.status(dictInfoService.removeBatchByIds(Func.toLongList(ids)));
|
|
|
}
|