diff --git a/flyfish-data/src/main/java/com/flyfish/framework/annotations/ComputedProps.java b/flyfish-data/src/main/java/com/flyfish/framework/annotations/ComputedProps.java index 848601d..064644a 100644 --- a/flyfish-data/src/main/java/com/flyfish/framework/annotations/ComputedProps.java +++ b/flyfish-data/src/main/java/com/flyfish/framework/annotations/ComputedProps.java @@ -1,31 +1,51 @@ package com.flyfish.framework.annotations; +import com.flyfish.framework.annotations.ComputedProps.List; + import java.lang.annotation.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + /** * 联动属性声明 + * * @author wangyu */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented +@Repeatable(List.class) public @interface ComputedProps { /** * 属性名 + * * @return 结果 */ String prop(); /** * 来自的字段值 + * * @return 结果 */ String field() default ""; /** * 表达式 + * * @return 结果 */ String expression() default ""; + + /** + * 可重复支持 + */ + @Target(ElementType.FIELD) + @Retention(RUNTIME) + @Documented + @interface List { + + ComputedProps[] value(); + } } diff --git a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java index efa8b28..b7dc810 100644 --- a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java +++ b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProperty.java @@ -144,9 +144,16 @@ public class BeanProperty { property.extra.put(BeanProps.COMPONENT, "input-hidden"); } // 追加属性映射 - MergedAnnotation links = annotations.get(ComputedProps.class); + MergedAnnotation links = annotations.get(ComputedProps.List.class); if (links.isPresent()) { - property.extra.put(BeanProps.LINKED, links.asMap()); + property.extra.put(BeanProps.LINKED, Arrays.stream( + links.getAnnotationArray("value", ComputedProps.class) + ).map(MergedAnnotation::asMap).collect(Collectors.toList())); + } else { + MergedAnnotation single = annotations.get(ComputedProps.class); + if (single.isPresent()) { + property.extra.put(BeanProps.LINKED, Collections.singletonList(links.asMap())); + } } // 优雅的设置额外的属性 MergedAnnotation item = annotations.get(FormItem.class);