|
@@ -25,7 +25,6 @@ import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
|
|
import org.dromara.common.excel.annotation.ExcelDynamicOptions;
|
|
import org.dromara.common.excel.annotation.ExcelDynamicOptions;
|
|
|
import org.dromara.common.excel.annotation.ExcelEnumFormat;
|
|
import org.dromara.common.excel.annotation.ExcelEnumFormat;
|
|
|
-import org.dromara.common.excel.service.ExcelOptionsProvider;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -122,15 +121,12 @@ public class ExcelDownHandler implements SheetWriteHandler {
|
|
|
} else if (field.isAnnotationPresent(ExcelDynamicOptions.class)) {
|
|
} else if (field.isAnnotationPresent(ExcelDynamicOptions.class)) {
|
|
|
// 处理动态下拉选项
|
|
// 处理动态下拉选项
|
|
|
ExcelDynamicOptions dynamicOptions = field.getDeclaredAnnotation(ExcelDynamicOptions.class);
|
|
ExcelDynamicOptions dynamicOptions = field.getDeclaredAnnotation(ExcelDynamicOptions.class);
|
|
|
- Class<?> providerClass = dynamicOptions.providerClass();
|
|
|
|
|
- if (providerClass == null) {
|
|
|
|
|
- throw new ServiceException("使用ExcelDynamicOptions注解,必须给providerClass赋予ExcelOptionsProvider的实现类" +
|
|
|
|
|
- ",字段:{}", field.getName());
|
|
|
|
|
- }
|
|
|
|
|
// 获取提供者实例
|
|
// 获取提供者实例
|
|
|
- ExcelOptionsProvider provider = (ExcelOptionsProvider) SpringUtils.getBean(providerClass);
|
|
|
|
|
- Set<String> optionSets = provider.getOptions();
|
|
|
|
|
- options = new ArrayList<>(CollUtil.isNotEmpty(optionSets) ? new ArrayList<>(optionSets) : Collections.emptyList());
|
|
|
|
|
|
|
+ ExcelOptionsProvider provider = SpringUtils.getBean(dynamicOptions.providerClass());
|
|
|
|
|
+ Set<String> providerOptions = provider.getOptions();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(providerOptions)) {
|
|
|
|
|
+ options = new ArrayList<>(providerOptions);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(options)) {
|
|
if (ObjectUtil.isNotEmpty(options)) {
|
|
|
// 仅当下拉可选项不为空时执行
|
|
// 仅当下拉可选项不为空时执行
|