feat:增加默认值的写入

This commit is contained in:
wangyu 2021-10-02 14:25:57 +08:00
parent c33cf2c38b
commit 25d00ec9bf
2 changed files with 10 additions and 6 deletions

View File

@ -259,14 +259,18 @@ public class BeanProperty {
String pattern = annotations.get(JsonFormat.class).synthesize().pattern(); String pattern = annotations.get(JsonFormat.class).synthesize().pattern();
// yyyy-MM-dd HH:mm:ss // yyyy-MM-dd HH:mm:ss
if (StringUtils.isNotBlank(pattern)) { if (StringUtils.isNotBlank(pattern)) {
if (pattern.length() == 7) { int length = pattern.length();
if (length == 7) {
property.prop("type", "month"); property.prop("type", "month");
} else if (pattern.length() == 10) { } else if (length == 10) {
property.prop("type", "date"); property.prop("type", "date");
} else if (pattern.length() == 16) { } else if (length == 11) {
property.prop("type", "date")
.prop("format", "YYYY年MM月DD日");
} else if (length == 16) {
property.prop("type", "datetime"); property.prop("type", "datetime");
property.prop("format", "YYYY-MM-DD HH:mm"); property.prop("format", "YYYY-MM-DD HH:mm");
} else if (pattern.length() > 16) { } else if (length > 16) {
property.prop("format", "YYYY-MM-DD HH:mm:ss"); property.prop("format", "YYYY-MM-DD HH:mm:ss");
} }
} }

View File

@ -24,9 +24,9 @@ public enum BeanPropertyType {
NUMBER("Number", "string", Number.class), NUMBER("Number", "string", Number.class),
BOOLEAN("Boolean", "boolean", Boolean.class), BOOLEAN("Boolean", "boolean", Boolean.class),
DATE("Date", "date", Date.class), DATE("Date", "date", Date.class),
ENUM("Enum", Enum.class), ENUM("Enum", "any", Enum.class),
LIST("Array", "array", Collection.class), LIST("Array", "array", Collection.class),
DB_REF("Ref", Po.class), DB_REF("Ref", "any", Po.class),
OBJECT("Object", "object", Object.class); OBJECT("Object", "object", Object.class);
private final BiPredicate<PropertyDescriptor, Class<?>> acceptor; private final BiPredicate<PropertyDescriptor, Class<?>> acceptor;