feat:增加查找替换逻辑
This commit is contained in:
parent
973040f363
commit
f5475190b5
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -144,9 +144,16 @@ public class BeanProperty {
|
||||
property.extra.put(BeanProps.COMPONENT, "input-hidden");
|
||||
}
|
||||
// 追加属性映射
|
||||
MergedAnnotation<ComputedProps> links = annotations.get(ComputedProps.class);
|
||||
MergedAnnotation<ComputedProps.List> 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<ComputedProps> single = annotations.get(ComputedProps.class);
|
||||
if (single.isPresent()) {
|
||||
property.extra.put(BeanProps.LINKED, Collections.singletonList(links.asMap()));
|
||||
}
|
||||
}
|
||||
// 优雅的设置额外的属性
|
||||
MergedAnnotation<FormItem> item = annotations.get(FormItem.class);
|
||||
|
Loading…
Reference in New Issue
Block a user