/**
* 分页
* @return
*/
@Bean
public PaginationInterceptor paginationInterceptor(){
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
ArrayList<ISqlParser> sqlParserList = new ArrayList<ISqlParser>();
TenantSqlParser tenantSqlParser = new TenantSqlParser();
tenantSqlParser.setTenantHandler(new TenantHandler() {
@Override
public Expression getTenantId(boolean where) {
return new LongValue(79657654768L);
}
@Override
public String getTenantIdColumn() {
return "parent_id";
}
@Override
public boolean doTableFilter(String tableName) {
//表示role表不是多租户
if("role".equals(tableName)){
return true;
}
return false;
}
});
sqlParserList.add(tenantSqlParser);
paginationInterceptor.setSqlParserList(sqlParserList);
//特定方法不使用多租户
paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() {
@Override
public boolean doFilter(MetaObject metaObject) {
MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
if("com.xiao.permission_system.UserInfoMapper.selectById".equals(ms.getId())){
return true;
}
return false;
}
});
return new PaginationInterceptor();
}
来源:oschina
链接:https://my.oschina.net/u/2427561/blog/3121376