Mybatis-plus自动填充字段
作者:
尼尔君 | 来源:发表于
2021-01-12 15:29 被阅读0次
@Configuration
@Component
public class MybatisMetaHandler implements MetaObjectHandler {
@Bean
public OptimisticLockerInterceptor OptimisticLockerInterceptor() {
return new OptimisticLockerInterceptor();
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
@Bean
public ConfigurationCustomizer configurationCustomizer() {
return configuration -> configuration.setUseDeprecatedExecutor(false);
}
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createTime",new Date(),metaObject);
}
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updateTime",new Date(),metaObject);
}
}
本文标题:Mybatis-plus自动填充字段
本文链接:https://www.haomeiwen.com/subject/zyqeaktx.html
网友评论