/**
-
自定义MetaObjectHandler
/
@Component
@AllArgsConstructor
public class MyMetaObjectHandler implements MetaObjectHandler {
/*- 新增的时候自动填充
- @param metaObject 数据对象
*/
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName(“createdId”, Long.valueOf(userUtil.getUserId()), metaObject);
this.setFieldValByName(“createdAt”, CommonUtils.getLocalDateTime(), metaObject);
this.setFieldValByName(“updatedId”, Long.valueOf(userUtil.getUserId()), metaObject);
this.setFieldValByName(“updatedAt”, CommonUtils.getLocalDateTime(), metaObject);
}
/**
- 更新后的字段会自动填充
- @param metaObject 数据对象
*/
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName(“updatedId”, Long.valueOf(userUtil.getUserId()), metaObject);
this.setFieldValByName(“updatedAt”, CommonUtils.getLocalDateTime(), metaObject);
}
}