/**
* mybatisplus的自动化填充
*/
public class JboltMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
this.strictInsertFill(metaObject, "createTime", Timestamp.class, Timestamp.valueOf(now));
}
@Override
public void updateFill(MetaObject metaObject) {
// 如果有更新时需要自动填充的字段,可以在这里添加
}
}
@Configuration
public class JboltBatisPlusConfig {
@Bean
public JboltMetaObjectHandler myMetaObjectHandler() {
return new JboltMetaObjectHandler();
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
}
实体类