use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project shopzz by whoiszxl.
the class MyBatisConfig method mybatisPlusInterceptor.
/**
* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project RottenSearch by yumo0.
the class MybatisPlusConfig method mybatisPlusInterceptor.
/**
* @Author: yumo
* 分页插件
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
// 设置数据库类型
paginationInnerInterceptor.setDbType(DbType.MYSQL);
// 设置请求的页面大于最大页后操作,true调回到首页,false继续请求,默认false
paginationInnerInterceptor.setOverflow(true);
// 设置最大单页限制数量,默认500条,-1表示不受限制
paginationInnerInterceptor.setMaxLimit(100L);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
return interceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project herodotus-engine by herodotus-cloud.
the class MybatisPlusConfiguration method mybatisPlusInterceptor.
/**
* 防止 修改与删除时对全表进行操作
* @return {@link MybatisPlusInterceptor}
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(parseDbType()));
log.trace("[Herodotus] |- Bean [Mybatis Plus Interceptor] Auto Configure.");
return mybatisPlusInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project heifer by galaxy-sea.
the class MybatisPlusConfig method mybatisPlusInterceptor.
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project helio-starters by uncarbon97.
the class HelioMybatisPlusAutoConfiguration method mybatisPlusInterceptor.
@Bean
@ConditionalOnMissingBean
public MybatisPlusInterceptor mybatisPlusInterceptor(TenantSupport tenantSupport) {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
/*
https://baomidou.com/pages/2976a3/#%E5%B1%9E%E6%80%A7
使用多个功能需要注意顺序关系,建议使用如下顺序
多租户,动态表名
分页,乐观锁
sql性能规范,防止全表更新与删除
*/
if (Boolean.TRUE.equals(helioProperties.getTenant().getEnabled())) {
// 配置文件中启用了多租户功能,注入对应支持 bean
tenantSupport.support(helioProperties, interceptor);
}
/*
分页插件
*/
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
// 设置sql的limit为无限制
paginationInnerInterceptor.setMaxLimit(-1L);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
/*
乐观锁
*/
if (Boolean.TRUE.equals(helioProperties.getCrud().getOptimisticLock().getEnabled())) {
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
}
/*
防止全表更新与删除
*/
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
return interceptor;
}
Aggregations