|
|
|
@ -39,6 +39,19 @@ public class DictDataController { |
|
|
|
throw new RuntimeException("当前字典已存在默认值"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(dictData.getDictType())){ |
|
|
|
throw new RuntimeException("字典类型为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(dictData.getDictValue())){ |
|
|
|
throw new RuntimeException("字典键值为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(dictData.getSite())){ |
|
|
|
throw new RuntimeException("工厂编码为空"); |
|
|
|
} |
|
|
|
List<DictData> list = dictDataService.list(new LambdaQueryWrapper<DictData>().eq(DictData::getDictValue, dictData.getDictValue()).eq(DictData::getDictType, dictData.getDictType()).eq(DictData::getSite, dictData.getSite())); |
|
|
|
if (null != list && !list.isEmpty()){ |
|
|
|
throw new RuntimeException("字典键值重复"); |
|
|
|
} |
|
|
|
if (dictDataService.save(dictData)) { |
|
|
|
return R.ok("保存成功!"); |
|
|
|
} |
|
|
|
@ -118,9 +131,32 @@ public class DictDataController { |
|
|
|
if (StringUtils.hasText(dictData.getIsDefault()) && dictData.getIsDefault().equals("Y")){ |
|
|
|
List<DictData> list = dictDataService.list(new LambdaQueryWrapper<DictData>().eq(DictData::getDictType, dictData.getDictType()).eq(DictData::getSite, dictData.getSite()).eq(DictData::getIsDefault,"Y")); |
|
|
|
if (null != list && !list.isEmpty()){ |
|
|
|
if (list.size() > 1){ |
|
|
|
throw new RuntimeException("当前字典已存在默认值"); |
|
|
|
} |
|
|
|
if (!list.get(0).getDictCode().equals(dictData.getDictCode())){ |
|
|
|
throw new RuntimeException("当前字典已存在默认值"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(dictData.getDictType())){ |
|
|
|
throw new RuntimeException("字典类型为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(dictData.getDictValue())){ |
|
|
|
throw new RuntimeException("字典键值为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(dictData.getSite())){ |
|
|
|
throw new RuntimeException("工厂编码为空"); |
|
|
|
} |
|
|
|
List<DictData> list = dictDataService.list(new LambdaQueryWrapper<DictData>().eq(DictData::getDictValue, dictData.getDictValue()).eq(DictData::getDictType, dictData.getDictType()).eq(DictData::getSite, dictData.getSite())); |
|
|
|
if (null != list && !list.isEmpty()){ |
|
|
|
if (list.size() > 1){ |
|
|
|
throw new RuntimeException("字典键值重复"); |
|
|
|
} |
|
|
|
if (!list.get(0).getDictCode().equals(dictData.getDictCode())){ |
|
|
|
throw new RuntimeException("字典键值重复"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (dictDataService.updateById(dictData)) { |
|
|
|
return R.ok("保存成功!"); |
|
|
|
} |
|
|
|
|