把pagehelper-spring-boot-starter包改成pagehelper,不自动配置改为手动配置顺序,例如分页前拦截数据权限:
@Configuration
public class MybatisInterceptorAutoConfiguration {
@Autowired
private ListsqlSessionFactoryList;
@Bean
@ConfigurationProperties(prefix = "pagehelper")
public Properties pageHelperProperties() {
return new Properties();
}
@PostConstruct
public void addMysqlInterceptor() {
//数据权限拦截器
DataPermissionInterceptor dataPermissionInterceptor = new DataPermissionInterceptor();
//分页拦截器
PageInterceptor pageInterceptor = new PageInterceptor();
pageInterceptor.setProperties(this.pageHelperProperties());
for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
sqlSessionFactory.getConfiguration().addInterceptor(pageInterceptor);
sqlSessionFactory.getConfiguration().addInterceptor(dataPermissionInterceptor);
}
}
}
自定义的拦截器和pagehelper是2个完全不同的东西啊
拦截器中可以执行pagehelper代码
多个拦截器有顺序,按照配置的顺序来。
我不太理解你的问题