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 new file mode 100644 index 0000000..848601d --- /dev/null +++ b/flyfish-data/src/main/java/com/flyfish/framework/annotations/ComputedProps.java @@ -0,0 +1,31 @@ +package com.flyfish.framework.annotations; + +import java.lang.annotation.*; + +/** + * 联动属性声明 + * @author wangyu + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ComputedProps { + + /** + * 属性名 + * @return 结果 + */ + String prop(); + + /** + * 来自的字段值 + * @return 结果 + */ + String field() default ""; + + /** + * 表达式 + * @return 结果 + */ + String expression() default ""; +} diff --git a/flyfish-data/src/main/java/com/flyfish/framework/annotations/MappedTo.java b/flyfish-data/src/main/java/com/flyfish/framework/annotations/MappedTo.java index 96625fc..f963588 100644 --- a/flyfish-data/src/main/java/com/flyfish/framework/annotations/MappedTo.java +++ b/flyfish-data/src/main/java/com/flyfish/framework/annotations/MappedTo.java @@ -1,7 +1,5 @@ package com.flyfish.framework.annotations; -import org.springframework.core.annotation.AliasFor; - import java.lang.annotation.*; /** 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 b207caf..efa8b28 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 @@ -143,6 +143,11 @@ public class BeanProperty { property.extra.put(BeanProps.GENERATED, generation.asMap()); property.extra.put(BeanProps.COMPONENT, "input-hidden"); } + // 追加属性映射 + MergedAnnotation links = annotations.get(ComputedProps.class); + if (links.isPresent()) { + property.extra.put(BeanProps.LINKED, links.asMap()); + } // 优雅的设置额外的属性 MergedAnnotation item = annotations.get(FormItem.class); if (item.isPresent()) { diff --git a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java index e8fa641..6a94b4d 100644 --- a/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java +++ b/flyfish-web/src/main/java/com/flyfish/framework/beans/meta/BeanProps.java @@ -30,6 +30,8 @@ public interface BeanProps { String GENERATED = "generated"; + String LINKED = "links"; + String MAPPING = "mapping"; String CONDITION = "condition";