feat: 增加db引用注解

This commit is contained in:
wangyu 2021-03-30 22:30:20 +08:00
parent eb5a7b5fb9
commit 452c52140e
2 changed files with 36 additions and 3 deletions

View File

@ -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();
}

View File

@ -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)) {