use of com.diboot.core.service.DictionaryServiceExtProvider in project diboot by dibo-software.
the class ExcelBindAnnoHandler method convertToNameValueMap.
/**
* 转换为name-value map
* @param annotation
* @param nameList
* @return
*/
public static Map<String, List> convertToNameValueMap(Annotation annotation, List<String> nameList) {
// 字典
if (annotation instanceof ExcelBindDict || annotation instanceof BindDict) {
String dictType = null;
if (annotation instanceof ExcelBindDict) {
dictType = ((ExcelBindDict) annotation).type();
} else {
dictType = ((BindDict) annotation).type();
}
DictionaryServiceExtProvider bindDictService = ContextHelper.getBean(DictionaryServiceExtProvider.class);
if (bindDictService == null) {
throw new InvalidUsageException("DictionaryService未实现,无法使用ExcelBindDict注解!");
}
List<LabelValue> list = bindDictService.getLabelValueList(dictType);
return convertLabelValueListToMap(list);
} else if (annotation instanceof ExcelBindField) {
ExcelBindField bindField = (ExcelBindField) annotation;
return executeBindField(bindField, nameList);
} else {
return Collections.emptyMap();
}
}
use of com.diboot.core.service.DictionaryServiceExtProvider in project diboot by dibo-software.
the class OptionWriteHandler method getDictOptions.
/**
* 从字典中获取选项
*
* @param dictType 字典类型
* @return 选项数组
*/
protected String[] getDictOptions(String dictType) {
DictionaryServiceExtProvider bindDictService = ContextHelper.getBean(DictionaryServiceExtProvider.class);
if (bindDictService == null) {
throw new InvalidUsageException("DictionaryService未实现,@ExcelOption无法关联字典!");
}
String[] options = bindDictService.getLabelValueList(dictType).stream().map(LabelValue::getLabel).toArray(String[]::new);
if (V.isEmpty(options)) {
log.warn(" @ExcelOption 关联字典: " + dictType + " 无值");
}
return options;
}
Aggregations