| | |
| | | |
| | | private static final String UPDATE_TIME = "updateTime"; |
| | | |
| | | |
| | | //自定义 |
| | | private static final String CREATE_DATE = "createDate"; |
| | | |
| | | private static final String UPDATE_DATE = "updateDate"; |
| | | |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | try { |
| | | |
| | | Object updateDate = metaObject.getValue(UPDATE_DATE); |
| | | if(ObjectUtil.isNull(updateDate)) { |
| | | setFieldValByName(UPDATE_DATE, new Date(), metaObject); |
| | | } |
| | | |
| | | Object createDate = metaObject.getValue(CREATE_DATE); |
| | | if(ObjectUtil.isNull(createDate)) { |
| | | setFieldValByName(CREATE_DATE, new Date(), metaObject); |
| | | } |
| | | |
| | | //为空则设置createUser(BaseEntity) |
| | | Object createUser = metaObject.getValue(CREATE_USER); |
| | | if(ObjectUtil.isNull(createUser)) { |
| | |
| | | if(ObjectUtil.isNull(createTime)) { |
| | | setFieldValByName(CREATE_TIME, new Date(), metaObject); |
| | | } |
| | | |
| | | } catch (ReflectionException e) { |
| | | log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理"); |
| | | } |
| | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | try { |
| | | setFieldValByName(UPDATE_DATE, new Date(), metaObject); |
| | | |
| | | //设置updateUser(BaseEntity) |
| | | setFieldValByName(UPDATE_USER, this.getUserUniqueId(), metaObject); |
| | | //设置updateTime(BaseEntity) |
| | | setFieldValByName(UPDATE_TIME, new Date(), metaObject); |
| | | |
| | | } catch (ReflectionException e) { |
| | | log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理"); |
| | | } |