feat: 增加db引用注解
This commit is contained in:
parent
69d4c62f35
commit
bcfb412c8b
@ -0,0 +1,14 @@
|
|||||||
|
package com.flyfish.framework.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期范围标记
|
||||||
|
*
|
||||||
|
* @author wangyu
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Documented
|
||||||
|
public @interface DateRange {
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.flyfish.framework.beans.meta;
|
package com.flyfish.framework.beans.meta;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.flyfish.framework.annotations.Properties;
|
import com.flyfish.framework.annotations.Properties;
|
||||||
import com.flyfish.framework.annotations.*;
|
import com.flyfish.framework.annotations.*;
|
||||||
import com.flyfish.framework.domain.base.Qo;
|
import com.flyfish.framework.domain.base.Qo;
|
||||||
@ -10,6 +11,7 @@ import lombok.Data;
|
|||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.apache.commons.collections4.ListUtils;
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.apache.commons.lang3.ClassUtils;
|
import org.apache.commons.lang3.ClassUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||||
import org.apache.commons.lang3.reflect.TypeUtils;
|
import org.apache.commons.lang3.reflect.TypeUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@ -119,9 +121,15 @@ public class BeanProperty {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LIST:
|
case LIST:
|
||||||
// 尝试获取泛型参数,存在时,赋值子表单
|
if (null != field) {
|
||||||
if (null != field && field.isAnnotationPresent(SubBean.class)) {
|
if (field.isAnnotationPresent(SubBean.class)) {
|
||||||
parseSubClass(field).ifPresent(subClazz -> property.setChildren(from(subClazz)));
|
// 尝试获取泛型参数,存在时,赋值子表单
|
||||||
|
parseSubClass(field).ifPresent(subClazz -> property.setChildren(from(subClazz)));
|
||||||
|
} else if (field.isAnnotationPresent(DateRange.class)) {
|
||||||
|
property.setType(BeanPropertyType.DATE);
|
||||||
|
property.prop("type", "range");
|
||||||
|
property.prop("placeholder", Arrays.asList("开始时间", "结束时间"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJECT:
|
case OBJECT:
|
||||||
@ -144,6 +152,23 @@ public class BeanProperty {
|
|||||||
String name = StringFormats.camel2Line(ClassUtils.getShortClassName(clazz));
|
String name = StringFormats.camel2Line(ClassUtils.getShortClassName(clazz));
|
||||||
property.prop("code", name);
|
property.prop("code", name);
|
||||||
break;
|
break;
|
||||||
|
case DATE:
|
||||||
|
// 为日期,自动放入类型和长度
|
||||||
|
if (null != field) {
|
||||||
|
if (field.isAnnotationPresent(JsonFormat.class)) {
|
||||||
|
String pattern = field.getAnnotation(JsonFormat.class).pattern();
|
||||||
|
// yyyy-MM-dd HH:mm:ss
|
||||||
|
if (StringUtils.isNotBlank(pattern)) {
|
||||||
|
if (pattern.length() == 7) {
|
||||||
|
property.prop("type", "month");
|
||||||
|
} else if (pattern.length() == 10) {
|
||||||
|
property.prop("type", "date");
|
||||||
|
} else if (pattern.length() > 16) {
|
||||||
|
property.prop("format", "YYYY-MM-DD HH:mm:ss");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user