fix: 分页拦截器改到租户拦截器之后注册
This commit is contained in:
@@ -40,8 +40,10 @@ public class MybatisPlusConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
// 分页拦截器必须注册,否则 selectPage 不会生成 LIMIT / COUNT
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
// 顺序很重要:MyBatis-Plus 要求「多租户 → 分页」。
|
||||
// 分页的 count 语句是从「当前已处理的 SQL」派生的;若分页先注册,
|
||||
// count 会在租户条件追加之前就派生出来,导致 total 把其他用户的行也算进去
|
||||
// (records 仍然正确,只有分页总数跨租户,极难发现)。
|
||||
interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new TenantLineHandler() {
|
||||
@Override
|
||||
public Expression getTenantId() {
|
||||
@@ -61,6 +63,8 @@ public class MybatisPlusConfig {
|
||||
return EXCLUDE_TABLES.contains(tableName.toLowerCase());
|
||||
}
|
||||
}));
|
||||
// 分页拦截器必须注册,否则 selectPage 不会生成 LIMIT / COUNT
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user