Search in sources :

Example 41 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor in project RottenSearch by yumo0.

the class MybatisPlusConfig method mybatisPlusInterceptor.

/**
 * @Author: yumo
 * 分页插件
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
    // 设置数据库类型
    paginationInnerInterceptor.setDbType(DbType.MYSQL);
    // 设置请求的页面大于最大页后操作,true调回到首页,false继续请求,默认false
    paginationInnerInterceptor.setOverflow(true);
    // 设置最大单页限制数量,默认500条,-1表示不受限制
    paginationInnerInterceptor.setMaxLimit(100L);
    interceptor.addInnerInterceptor(paginationInnerInterceptor);
    return interceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 42 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor in project herodotus-engine by herodotus-cloud.

the class MybatisPlusConfiguration method mybatisPlusInterceptor.

/**
 * 防止 修改与删除时对全表进行操作
 * @return {@link MybatisPlusInterceptor}
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
    mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(parseDbType()));
    log.trace("[Herodotus] |- Bean [Mybatis Plus Interceptor] Auto Configure.");
    return mybatisPlusInterceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 43 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor in project heifer by galaxy-sea.

the class MybatisPlusConfig method mybatisPlusInterceptor.

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    return interceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 44 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor in project helio-starters by uncarbon97.

the class HelioMybatisPlusAutoConfiguration method mybatisPlusInterceptor.

@Bean
@ConditionalOnMissingBean
public MybatisPlusInterceptor mybatisPlusInterceptor(TenantSupport tenantSupport) {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    /*
        https://baomidou.com/pages/2976a3/#%E5%B1%9E%E6%80%A7
        使用多个功能需要注意顺序关系,建议使用如下顺序

        多租户,动态表名
        分页,乐观锁
        sql性能规范,防止全表更新与删除
         */
    if (Boolean.TRUE.equals(helioProperties.getTenant().getEnabled())) {
        // 配置文件中启用了多租户功能,注入对应支持 bean
        tenantSupport.support(helioProperties, interceptor);
    }
    /*
        分页插件
         */
    PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
    // 设置sql的limit为无限制
    paginationInnerInterceptor.setMaxLimit(-1L);
    interceptor.addInnerInterceptor(paginationInnerInterceptor);
    /*
        乐观锁
         */
    if (Boolean.TRUE.equals(helioProperties.getCrud().getOptimisticLock().getEnabled())) {
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    }
    /*
        防止全表更新与删除
         */
    interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
    return interceptor;
}
Also used : BlockAttackInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor) MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 45 with PaginationInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor 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;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)104 Bean (org.springframework.context.annotation.Bean)95 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)94 OptimisticLockerInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor)15 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)14 BlockAttackInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor)11 TenantLineInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor)6 InnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor)4 TenantLineHandler (com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler)3 MybatisSqlSessionFactoryBean (com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean)3 Expression (net.sf.jsqlparser.expression.Expression)3 Order (org.springframework.core.annotation.Order)3 MybatisConfiguration (com.baomidou.mybatisplus.core.MybatisConfiguration)2 IllegalSQLInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor)2 LongValue (net.sf.jsqlparser.expression.LongValue)2 StringValue (net.sf.jsqlparser.expression.StringValue)2 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)2 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)2 TenantLineHandler (com.albedo.java.plugins.database.handler.TenantLineHandler)1 SchemaInterceptor (com.albedo.java.plugins.database.interceptor.SchemaInterceptor)1