feat: 增加db引用注解
This commit is contained in:
parent
eb5a7b5fb9
commit
452c52140e
@ -0,0 +1,24 @@
|
||||
package com.flyfish.framework.annotations;
|
||||
|
||||
import com.flyfish.framework.domain.base.Po;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 数据库值标记
|
||||
*
|
||||
* @author wangyu
|
||||
* 可以提供元数据的配置
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
@Documented
|
||||
public @interface DBRefValue {
|
||||
|
||||
/**
|
||||
* 提供明确的类型
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
Class<? extends Po> value();
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.flyfish.framework.beans.meta;
|
||||
|
||||
import com.flyfish.framework.annotations.DictValue;
|
||||
import com.flyfish.framework.annotations.EnumValue;
|
||||
import com.flyfish.framework.annotations.*;
|
||||
import com.flyfish.framework.annotations.Properties;
|
||||
import com.flyfish.framework.annotations.Property;
|
||||
import com.flyfish.framework.domain.base.Qo;
|
||||
import com.flyfish.framework.domain.base.Vo;
|
||||
import com.flyfish.framework.utils.DataUtils;
|
||||
@ -106,8 +104,19 @@ public class BeanProperty {
|
||||
EnumValue enumValue = field.getAnnotation(EnumValue.class);
|
||||
String name = StringFormats.camel2Line(ClassUtils.getShortClassName(enumValue.value()));
|
||||
property.prop("code", name);
|
||||
} else if (field.isAnnotationPresent(DBRefValue.class)) {
|
||||
// 添加了数据库引用注解,自动注入类型给前端使用
|
||||
property.setType(BeanPropertyType.DB_REF);
|
||||
DBRefValue dbRefValue = field.getAnnotation(DBRefValue.class);
|
||||
Document document = AnnotationUtils.findAnnotation(dbRefValue.value(), Document.class);
|
||||
if (null != document) {
|
||||
property.prop("uri", document.value());
|
||||
} else {
|
||||
property.setType(BeanPropertyType.STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LIST:
|
||||
// 尝试获取泛型参数,存在时,赋值子表单
|
||||
if (null != field && field.isAnnotationPresent(SubBean.class)) {
|
||||
|
Loading…
Reference in New Issue
Block a user