use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project mybatis-plus-samples by baomidou.
the class DbConfigurations method mybatisPlusInterceptor.
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return mybatisPlusInterceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project muses by acgist.
the class MyBatisAutoConfiguration method mybatisPlusInterceptor.
@Bean
@ConditionalOnMissingBean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
final MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project sakura-boot by yanjingfan.
the class MybatisPlusConfig method tenantPaginationInterceptor.
/**
* 多租户分页
* @return
*/
@ConditionalOnProperty(prefix = "tenant", name = "column")
@Bean
public MybatisPlusInterceptor tenantPaginationInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
TenantLineInnerInterceptor tenantInnerInterceptor = new TenantLineInnerInterceptor();
tenantInnerInterceptor.setTenantLineHandler(new TenantLineHandler() {
@Override
public Expression getTenantId() {
// 可将租户id和租户字段放置在请求头中
try {
String tenantId = request.getHeader("tenantId");
if (tenantId == null || "".equals(tenantId.trim())) {
return new LongValue(-1);
}
return new LongValue(Long.parseLong(tenantId));
} catch (Exception e) {
return new LongValue(-1);
}
}
@Override
public String getTenantIdColumn() {
return environment.getProperty("tenant.column");
// 可将租户id和租户字段放置在请求头中
// return request.getHeader("tenantColumn");
}
@Override
public boolean ignoreTable(String tableName) {
// 忽略uid-generator模块相关表
if ("worker_node".equalsIgnoreCase(tableName)) {
return true;
}
return false;
}
});
interceptor.addInnerInterceptor(tenantInnerInterceptor);
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project sakura-boot by yanjingfan.
the class MybatisPlusConfig method mybatisPlusInterceptor.
/**
* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
*/
@Conditional(ConditionOnMissingTenantProperty.class)
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 默认为Mysql
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project Taier by DTStack.
the class MybatisConfig method mybatisPlusInterceptor.
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
Aggregations