|
|
@@ -31,18 +31,30 @@ public class BaseFieldFillHandler implements MetaObjectHandler { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void insertFill(MetaObject metaObject) { |
|
|
|
long userId = getUserId(); |
|
|
|
fillVal(CREATE_BY, metaObject, getUserId()); |
|
|
|
fillVal(UPDATE_BY, metaObject, getUserId()); |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
this.fillStrategy(metaObject, CREATE_BY, userId); |
|
|
|
this.fillStrategy(metaObject, CREATE_ON, now); |
|
|
|
this.fillStrategy(metaObject, UPDATE_BY, userId); |
|
|
|
this.fillStrategy(metaObject, UPDATE_ON, now); |
|
|
|
fillVal(CREATE_ON, metaObject, now); |
|
|
|
fillVal(UPDATE_ON, metaObject, now); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateFill(MetaObject metaObject) { |
|
|
|
this.fillStrategy(metaObject, UPDATE_BY, getUserId()); |
|
|
|
this.fillStrategy(metaObject, UPDATE_ON, LocalDateTime.now()); |
|
|
|
fillVal(UPDATE_BY, metaObject, getUserId()); |
|
|
|
fillVal(UPDATE_ON, metaObject, LocalDateTime.now()); |
|
|
|
} |
|
|
|
|
|
|
|
private void fillVal(String fieldName, MetaObject metaObject, Object val) { |
|
|
|
if (metaObject.hasSetter(fieldName)) { |
|
|
|
Class<?> setterType = metaObject.getSetterType(fieldName); |
|
|
|
if (setterType != null) { |
|
|
|
if (setterType.equals(String.class)) { |
|
|
|
this.fillStrategy(metaObject, fieldName, val.toString()); |
|
|
|
} else { |
|
|
|
this.fillStrategy(metaObject, fieldName, val); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |