Search in sources :

Example 1 with BladePaginationInterceptor

use of org.springblade.core.mp.plugins.BladePaginationInterceptor in project blade-tool by chillzhuang.

the class MybatisPlusConfiguration method mybatisPlusInterceptor.

/**
 * mybatis-plus 拦截器集合
 */
@Bean
@ConditionalOnMissingBean(MybatisPlusInterceptor.class)
public MybatisPlusInterceptor mybatisPlusInterceptor(ObjectProvider<QueryInterceptor[]> queryInterceptors, TenantLineInnerInterceptor tenantLineInnerInterceptor, MybatisPlusProperties mybatisPlusProperties) {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    // 配置租户拦截器
    interceptor.addInnerInterceptor(tenantLineInnerInterceptor);
    // 配置分页拦截器
    BladePaginationInterceptor paginationInterceptor = new BladePaginationInterceptor();
    // 配置自定义查询拦截器
    QueryInterceptor[] queryInterceptorArray = queryInterceptors.getIfAvailable();
    if (ObjectUtil.isNotEmpty(queryInterceptorArray)) {
        AnnotationAwareOrderComparator.sort(queryInterceptorArray);
        paginationInterceptor.setQueryInterceptors(queryInterceptorArray);
    }
    paginationInterceptor.setMaxLimit(mybatisPlusProperties.getPageLimit());
    paginationInterceptor.setOverflow(mybatisPlusProperties.getOverflow());
    interceptor.addInnerInterceptor(paginationInterceptor);
    return interceptor;
}
Also used : BladePaginationInterceptor(org.springblade.core.mp.plugins.BladePaginationInterceptor) QueryInterceptor(org.springblade.core.mp.intercept.QueryInterceptor) MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)1 QueryInterceptor (org.springblade.core.mp.intercept.QueryInterceptor)1 BladePaginationInterceptor (org.springblade.core.mp.plugins.BladePaginationInterceptor)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1