|
|
|
@ -25,23 +25,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataDao, DictData> impl |
|
|
|
throw new RuntimeException("字典数据为空"); |
|
|
|
} |
|
|
|
// 设置为默认值 |
|
|
|
if (StringUtils.hasText(dictData.getIsDefault()) && dictData.getIsDefault().equals("Y")){ |
|
|
|
// List<DictData> list = list(new LambdaQueryWrapper<DictData>().eq(DictData::getDictType, dictData.getDictType()).eq(DictData::getSite, dictData.getSite()).eq(DictData::getIsDefault,"Y")); |
|
|
|
// if (null != list && !list.isEmpty()){ |
|
|
|
// throw new RuntimeException("当前字典已存在默认值"); |
|
|
|
// } |
|
|
|
lambdaUpdate().set(DictData::getIsDefault,Constant.SYSTEM_ACTIVE_YES).eq(DictData::getDictType,dictData.getDictType()).eq(DictData::getSite,dictData.getSite()).update(); |
|
|
|
} |
|
|
|
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 = list(new LambdaQueryWrapper<DictData>().eq(DictData::getDictValue, dictData.getDictValue()).eq(DictData::getDictType, dictData.getDictType()).eq(DictData::getSite, dictData.getSite())); |
|
|
|
List<DictData> list =isDefault(dictData); |
|
|
|
if (null != list && !list.isEmpty()){ |
|
|
|
throw new RuntimeException("字典键值重复"); |
|
|
|
} |
|
|
|
@ -53,7 +37,20 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataDao, DictData> impl |
|
|
|
if (Objects.isNull(dictData)||Objects.isNull(dictData.getDictCode())){ |
|
|
|
throw new RuntimeException("字典数据为空"); |
|
|
|
} |
|
|
|
if (StringUtils.hasText(dictData.getIsDefault()) && dictData.getIsDefault().equals("Y")){ |
|
|
|
List<DictData> list = isDefault(dictData);; |
|
|
|
if (null != list && !list.isEmpty()){ |
|
|
|
if (list.size() > 1){ |
|
|
|
throw new RuntimeException("字典键值重复"); |
|
|
|
} |
|
|
|
if (!list.get(0).getDictCode().equals(dictData.getDictCode())){ |
|
|
|
throw new RuntimeException("字典键值重复"); |
|
|
|
} |
|
|
|
} |
|
|
|
return updateById(dictData); |
|
|
|
} |
|
|
|
|
|
|
|
private List<DictData> isDefault(DictData dictData) { |
|
|
|
if (StringUtils.hasText(dictData.getIsDefault()) && dictData.getIsDefault().equals(Constant.SYSTEM_ACTIVE_YES)){ |
|
|
|
// List<DictData> list = 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){ |
|
|
|
@ -74,15 +71,6 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataDao, DictData> impl |
|
|
|
if (!StringUtils.hasText(dictData.getSite())){ |
|
|
|
throw new RuntimeException("工厂编码为空"); |
|
|
|
} |
|
|
|
List<DictData> list = 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("字典键值重复"); |
|
|
|
} |
|
|
|
} |
|
|
|
return updateById(dictData); |
|
|
|
return list(new LambdaQueryWrapper<DictData>().eq(DictData::getDictValue, dictData.getDictValue()).eq(DictData::getDictType, dictData.getDictType()).eq(DictData::getSite, dictData.getSite())); |
|
|
|
} |
|
|
|
} |