use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project kms by mahonelau.
the class MybatisPlusConfig method paginationInterceptor.
/**
* 多租户属于 SQL 解析部分,依赖 MP 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor().setLimit(-1);
// 多租户配置 配置后每次执行sql会走一遍他的转化器 如果不需要多租户功能 可以将其注释
tenantConfig(paginationInterceptor);
return paginationInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project wakaka by Crysmart.
the class MyBatisConfig method paginationInterceptor.
/**
* MP 自带分页插件
* @return
*/
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor page = new PaginationInterceptor();
page.setDialectType("mysql");
return page;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project spring-boot-web by wangchengming666.
the class MybatisPlusConfig method paginationInterceptor.
/**
* mybatis-plus分页插件<br>
* 文档:http://mp.baomidou.com<br>
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setDialectType("mysql");
return paginationInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project ddf-common by dongfangding.
the class MyBatisConfig method paginationInterceptor.
/**
* 分页与攻击 SQL 阻断解析器
*
* @return
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
List<ISqlParser> sqlParserList = new ArrayList<>();
// 攻击 SQL 阻断解析器、加入解析链
sqlParserList.add(new BlockAttackSqlParser());
paginationInterceptor.setSqlParserList(sqlParserList);
return paginationInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor in project jshERP by jishenghua.
the class TenantConfig method paginationInterceptor.
@Bean
public PaginationInterceptor paginationInterceptor(HttpServletRequest request) {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
List<ISqlParser> sqlParserList = new ArrayList<>();
TenantSqlParser tenantSqlParser = new TenantSqlParser();
tenantSqlParser.setTenantHandler(new TenantHandler() {
@Override
public Expression getTenantId() {
String token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if (tenantId != 0L) {
return new LongValue(tenantId);
} else {
// 超管
return null;
}
}
@Override
public String getTenantIdColumn() {
return "tenant_id";
}
@Override
public boolean doTableFilter(String tableName) {
// 获取开启状态
Boolean res = true;
String token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if (tenantId != 0L) {
// 这里可以判断是否过滤表
if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName) || "jsh_user_business".equals(tableName) || "jsh_function".equals(tableName) || "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) {
res = true;
} else {
res = false;
}
}
return res;
}
});
sqlParserList.add(tenantSqlParser);
paginationInterceptor.setSqlParserList(sqlParserList);
paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() {
@Override
public boolean doFilter(MetaObject metaObject) {
MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
// 过滤自定义查询此时无租户信息约束出现
if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())) {
return true;
} else if ("com.jsh.erp.datasource.mappers.RoleMapperEx.getRoleWithoutTenant".equals(ms.getId())) {
return true;
} else if ("com.jsh.erp.datasource.mappers.LogMapperEx.insertLogWithUserId".equals(ms.getId())) {
return true;
}
return false;
}
});
return paginationInterceptor;
}
Aggregations