Search in sources :

Example 1 with BlockAttackInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor in project Open-Job by lijunping365.

the class MyBatisPlusConfig method mybatisPlusInterceptor.

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    final MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
    // 分页插件
    mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    // 乐观锁插件
    mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    // sql性能规范插件
    // mybatisPlusInterceptor.addInnerInterceptor(new IllegalSQLInnerInterceptor());
    // 防止全表更新与删除插件
    mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
    return mybatisPlusInterceptor;
}
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) Bean(org.springframework.context.annotation.Bean)

Example 2 with BlockAttackInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor in project learn-simple by muggle0.

the class MybatisPlusConfig method mybatisPlusInterceptor.

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    // 分页插件
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
    // 防止全表更新插件
    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) Bean(org.springframework.context.annotation.Bean)

Example 3 with BlockAttackInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor in project ieasy-server by baayso.

the class MybatisPlusConfig method mybatisPlusInterceptor.

/**
 * mybatis-plus 插件
 * <p>
 * 文档:https://baomidou.com/pages/2976a3/
 * <p>
 * 使用多个功能需要注意顺序关系,建议使用如下顺序<br>
 * 1) 多租户,动态表名<br>
 * 2) 分页,乐观锁<br>
 * 3) sql 性能规范,防止全表更新与删除<br>
 * 总结: 对 sql 进行单次改造的优先放入,不对 sql 进行改造的最后放入
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    // 防止全表更新与删除插件
    interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
    // 多租户插件
    TenantLineInnerInterceptor tenantLineInnerInterceptor = new TenantLineInnerInterceptor();
    // 行级租户SQL解析器
    tenantLineInnerInterceptor.setTenantLineHandler(new BasicTenantLineHandler());
    interceptor.addInnerInterceptor(tenantLineInnerInterceptor);
    // 分页插件
    // 如果使用了分页插件注意先 add TenantLineInnerInterceptor 再 add PaginationInnerInterceptor
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    // 乐观锁插件
    interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    return interceptor;
}
Also used : TenantLineInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor) 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) Bean(org.springframework.context.annotation.Bean)

Example 4 with BlockAttackInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor in project demo-SpringBoot by Max-Qiu.

the class MybatisPlusConfig method paginationInterceptor.

@Bean
public MybatisPlusInterceptor paginationInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    // 添加分页插件
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    // 添加 攻击 SQL 阻断解析器,防止全表更新与删除
    interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
    // 添加 乐观锁 插件
    interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    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) Bean(org.springframework.context.annotation.Bean)

Example 5 with BlockAttackInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor in project project by Ahaochan.

the class MyBatisPlusConfig method mybatisPlusInterceptor.

/**
 * @see <a href="https://mp.baomidou.com/guide/interceptor.html">插件主体(必看!)(since 3.4.0)</a>
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
    List<InnerInterceptor> innerInterceptors = Arrays.asList(// new TenantLineInnerInterceptor(), new DynamicTableNameInnerInterceptor(),
    new PaginationInnerInterceptor(), new OptimisticLockerInnerInterceptor(), // update 和 delete 必须要有 where
    new BlockAttackInnerInterceptor());
    mybatisPlusInterceptor.setInterceptors(innerInterceptors);
    return mybatisPlusInterceptor;
}
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) BlockAttackInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor) InnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Aggregations

BlockAttackInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor)14 Bean (org.springframework.context.annotation.Bean)14 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)13 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)11 OptimisticLockerInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor)7 InnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor)4 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)4 IllegalSQLInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor)2 TenantLineInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor)2 Expression (net.sf.jsqlparser.expression.Expression)2 StringValue (net.sf.jsqlparser.expression.StringValue)2 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)2 Order (org.springframework.core.annotation.Order)2 TenantLineHandler (com.albedo.java.plugins.database.handler.TenantLineHandler)1 SchemaInterceptor (com.albedo.java.plugins.database.interceptor.SchemaInterceptor)1 TenantLineInnerInterceptor (com.albedo.java.plugins.database.interceptor.TenantLineInnerInterceptor)1 TenantLineHandler (com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler)1 SchemaInterceptor (top.tangyh.basic.database.plugins.SchemaInterceptor)1