| | |
| | | try { |
| | | |
| | | Object updateDate = metaObject.getValue(UPDATE_DATE); |
| | | if(ObjectUtil.isNull(updateDate)) { |
| | | if (ObjectUtil.isNull(updateDate)) { |
| | | setFieldValByName(UPDATE_DATE, new Date(), metaObject); |
| | | } |
| | | |
| | | Object createDate = metaObject.getValue(CREATE_DATE); |
| | | if(ObjectUtil.isNull(createDate)) { |
| | | 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(createUser)) { |
| | | setFieldValByName(CREATE_USER, this.getUserUniqueId(), metaObject); |
| | | } |
| | | |
| | | //为空则设置createTime(BaseEntity) |
| | | Object createTime = metaObject.getValue(CREATE_TIME); |
| | | if(ObjectUtil.isNull(createTime)) { |
| | | if (ObjectUtil.isNull(createTime)) { |
| | | setFieldValByName(CREATE_TIME, new Date(), metaObject); |
| | | } |
| | | |
| | | } catch (ReflectionException e) { |
| | | log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理"); |
| | | //二次设置 |
| | | try { |
| | | //为空则设置createTime(BaseEntity) |
| | | Object createTime = metaObject.getValue(CREATE_TIME); |
| | | if (ObjectUtil.isNull(createTime)) { |
| | | setFieldValByName(CREATE_TIME, new Date(), metaObject); |
| | | } |
| | | //为空则设置createUser(BaseEntity) |
| | | Object createUser = metaObject.getValue(CREATE_USER); |
| | | if (ObjectUtil.isNull(createUser)) { |
| | | setFieldValByName(CREATE_USER, this.getUserUniqueId(), metaObject); |
| | | } |
| | | } catch (ReflectionException ex) { |
| | | log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理"); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | private Long getUserUniqueId() { |
| | | try { |
| | | SysLoginUser sysLoginUser = LoginContextHolder.me().getSysLoginUserWithoutException(); |
| | | if(ObjectUtil.isNotNull(sysLoginUser)) { |
| | | if (ObjectUtil.isNotNull(sysLoginUser)) { |
| | | return sysLoginUser.getId(); |
| | | } else { |
| | | return -1L; |