feat: 增加上传组件链接

This commit is contained in:
wangyu 2021-04-07 17:08:55 +08:00
parent dfab218c77
commit 3566c9facf
2 changed files with 26 additions and 4 deletions

View File

@ -340,14 +340,36 @@ public class ReflectionUtils {
/**
* 获取范型默认取得第一个
*
* @param clazz
* @return 结果
*/
public static Optional<Class<?>> getGenericType(Class<?> clazz) {
ParameterizedType type = CastUtils.cast(clazz.getGenericSuperclass());
return getGenericType(type);
}
/**
* 通过类型获取泛型
*
* @param type 类型
* @return 结果
*/
public static Optional<Class<?>> getGenericType(ParameterizedType type) {
return Optional.ofNullable(type.getActualTypeArguments()).filter(ArrayUtils::isNotEmpty)
.map(array -> array[0])
.filter(beanType -> beanType instanceof Class)
.map(beanType -> (Class<?>) beanType);
}
/**
* 获取字段域的泛型
*
* @param field 字段
* @return 结果
*/
public static Optional<Class<?>> getGenericType(Field field) {
ParameterizedType type = CastUtils.cast(field.getGenericType());
return getGenericType(type);
}
}

View File

@ -122,11 +122,11 @@ public class BeanProperty {
}
break;
case LIST:
// 是附件展现附件列表
ReflectionUtils.getGenericType(descriptor.getPropertyType())
.filter(property::isAttachment)
.ifPresent(item -> property.prop("attachment", true));
if (null != field) {
// 是附件展现附件列表
ReflectionUtils.getGenericType(field)
.filter(property::isAttachment)
.ifPresent(item -> property.prop("attachment", true));
if (field.isAnnotationPresent(SubBean.class)) {
// 尝试获取泛型参数存在时赋值子表单
parseSubClass(field).ifPresent(subClazz -> property.setChildren(from(subClazz)));