fix: 新增字典处理
This commit is contained in:
parent
df3748068a
commit
5e21b17f8e
@ -54,25 +54,29 @@ public class DictionaryProcessor implements InitializingBean {
|
|||||||
BlankEnum.class != annotation.enumType())
|
BlankEnum.class != annotation.enumType())
|
||||||
.map(annotation -> dictionaryService
|
.map(annotation -> dictionaryService
|
||||||
.getByCode(annotation.value())
|
.getByCode(annotation.value())
|
||||||
.map(dictionary -> {
|
.map(dictionary -> applyDictProps(dictionary, annotation))
|
||||||
if (CollectionUtils.isEmpty(dictionary.getValues())) {
|
.orElseGet(() -> applyDictProps(new Dictionary(), annotation)))
|
||||||
dictionary.setValues(mapValues(annotation.enumType()));
|
|
||||||
}
|
|
||||||
return dictionary;
|
|
||||||
})
|
|
||||||
.orElseGet(() -> {
|
|
||||||
Dictionary dictionary = new Dictionary();
|
|
||||||
dictionary.setCode(annotation.value());
|
|
||||||
dictionary.setValues(mapValues(annotation.enumType()));
|
|
||||||
dictionary.setName(StringUtils.isNotBlank(annotation.name()) ? annotation.name() : annotation.value());
|
|
||||||
return dictionary;
|
|
||||||
}))
|
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
dictionaryService.updateBatch(dictionaries);
|
dictionaryService.updateBatch(dictionaries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给字典属性赋值
|
||||||
|
*
|
||||||
|
* @param dictionary 字典
|
||||||
|
* @param annotation 注解
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
private Dictionary applyDictProps(Dictionary dictionary, DictValue annotation) {
|
||||||
|
dictionary.setCode(annotation.value());
|
||||||
|
if (CollectionUtils.isEmpty(dictionary.getValues())) {
|
||||||
|
dictionary.setValues(mapValues(annotation.enumType()));
|
||||||
|
}
|
||||||
|
dictionary.setName(StringUtils.isNotBlank(annotation.name()) ? annotation.name() : annotation.value());
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 映射值,转换为字典表的值
|
* 映射值,转换为字典表的值
|
||||||
|
Loading…
x
Reference in New Issue
Block a user