feat: 增加上传组件链接
This commit is contained in:
parent
dfab218c77
commit
3566c9facf
@ -340,14 +340,36 @@ public class ReflectionUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取范型,默认取得第一个
|
* 获取范型,默认取得第一个
|
||||||
|
*
|
||||||
* @param clazz 类
|
* @param clazz 类
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Optional<Class<?>> getGenericType(Class<?> clazz) {
|
public static Optional<Class<?>> getGenericType(Class<?> clazz) {
|
||||||
ParameterizedType type = CastUtils.cast(clazz.getGenericSuperclass());
|
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)
|
return Optional.ofNullable(type.getActualTypeArguments()).filter(ArrayUtils::isNotEmpty)
|
||||||
.map(array -> array[0])
|
.map(array -> array[0])
|
||||||
.filter(beanType -> beanType instanceof Class)
|
.filter(beanType -> beanType instanceof Class)
|
||||||
.map(beanType -> (Class<?>) beanType);
|
.map(beanType -> (Class<?>) beanType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字段域的泛型
|
||||||
|
*
|
||||||
|
* @param field 字段
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static Optional<Class<?>> getGenericType(Field field) {
|
||||||
|
ParameterizedType type = CastUtils.cast(field.getGenericType());
|
||||||
|
return getGenericType(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,11 +122,11 @@ public class BeanProperty {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LIST:
|
case LIST:
|
||||||
// 是附件,展现附件列表
|
|
||||||
ReflectionUtils.getGenericType(descriptor.getPropertyType())
|
|
||||||
.filter(property::isAttachment)
|
|
||||||
.ifPresent(item -> property.prop("attachment", true));
|
|
||||||
if (null != field) {
|
if (null != field) {
|
||||||
|
// 是附件,展现附件列表
|
||||||
|
ReflectionUtils.getGenericType(field)
|
||||||
|
.filter(property::isAttachment)
|
||||||
|
.ifPresent(item -> property.prop("attachment", true));
|
||||||
if (field.isAnnotationPresent(SubBean.class)) {
|
if (field.isAnnotationPresent(SubBean.class)) {
|
||||||
// 尝试获取泛型参数,存在时,赋值子表单
|
// 尝试获取泛型参数,存在时,赋值子表单
|
||||||
parseSubClass(field).ifPresent(subClazz -> property.setChildren(from(subClazz)));
|
parseSubClass(field).ifPresent(subClazz -> property.setChildren(from(subClazz)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user