Search in sources :

Example 1 with OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor 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 OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor in project sduoj-server by SDUOJ.

the class MyBatisPlusConfig method mybatisPlusInterceptor.

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    return interceptor;
}
Also used : 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 3 with OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor 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 OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor 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 OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor in project wandering by ShenJinyong.

the class MybatisPlusConfig method mybatisPlusInterceptor.

// 注册乐观锁插件
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
    mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    return mybatisPlusInterceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Aggregations

OptimisticLockerInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor)19 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)18 Bean (org.springframework.context.annotation.Bean)17 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)15 BlockAttackInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor)7 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)4 InnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor)3 TenantLineInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor)2 DataScopeInterceptor (com.albedo.java.plugins.database.mybatis.datascope.DataScopeInterceptor)1 MybatisConfiguration (com.baomidou.mybatisplus.core.MybatisConfiguration)1 MybatisMapWrapperFactory (com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory)1 DataPermissionInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor)1 MybatisSqlSessionFactoryBean (com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean)1 ArrayList (java.util.ArrayList)1 CustomDataPermissionHandler (org.dshubs.odc.mybatis.config.permission.handler.CustomDataPermissionHandler)1 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)1 MapperFactoryBean (org.mybatis.spring.mapper.MapperFactoryBean)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1