use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project springboot-learning by lyb-geek.
the class MyBatisPlusTenantConfig method paginationInterceptor.
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
if (myBatisPlusTenantProperties.isEnabled()) {
tenantHandler(paginationInterceptor);
}
return paginationInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project JBM by numen06.
the class MybatisPlusConfig method paginationInterceptor.
/**
* 分页拦截器
*
* @return
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setDialectType("mysql");
List<ISqlParser> sqlParserList = new ArrayList<>();
// TenantSqlParser tenantSqlParser = new TenantSqlParser();
// tenantSqlParser.setTenantHandler(new TenantHandler() {
// @Override
// public Expression getTenantId() {
// return new LongValue(1L);
// }
//
// @Override
// public String getTenantIdColumn() {
// return "tenant_id";
// }
//
// @Override
// public boolean doTableFilter(String tableName) {
// // 这里可以判断是否过滤表
// /*
// * if ("user".equals(tableName)) { return true; }
// */
// return false;
// }
// });
paginationInterceptor.setSqlParserList(sqlParserList);
// });
return paginationInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project study-by-myself by Howinfun.
the class MybatisPlusConfig method paginationInterceptor.
@Bean
public PaginationInterceptor paginationInterceptor() {
final PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setLimit(-1);
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project poseidon by muggle0.
the class MybatisPlusConfig method createSqlSessionFactoryBean.
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory createSqlSessionFactoryBean(@Qualifier(value = "globalConfig") GlobalConfig configuration) throws Exception {
log.info("初始化SqlSessionFactory");
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
Interceptor[] interceptor = { new PaginationInterceptor() };
sqlSessionFactoryBean.setPlugins(interceptor);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
// sqlSessionFactoryBean.setTypeHandlers(new TypeHandler[]{new MybatisDataHandler()});
try {
sqlSessionFactoryBean.setGlobalConfig(configuration);
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(mapperLocations));
sqlSessionFactoryBean.setTypeAliasesPackage(typeAliasesPackage);
return sqlSessionFactoryBean.getObject();
} catch (Exception e) {
e.printStackTrace();
}
return sqlSessionFactoryBean.getObject();
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project mall-learning by macrozheng.
the class MyBatisConfig method paginationInterceptor.
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}
Aggregations