Search in sources :

Example 6 with OptimisticLockerInnerInterceptor

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

Example 7 with OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor in project bubble-fireworks by fxbin.

the class MybatisPlusAutoConfiguration 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) MapperFactoryBean(org.mybatis.spring.mapper.MapperFactoryBean) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with OptimisticLockerInnerInterceptor

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

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor in project albedo by somowhere.

the class AuthorityMybatisAutoConfiguration method getPaginationBeforeInnerInterceptor.

/**
 * 数据权限插件
 *
 * @return 数据权限插件
 */
@Override
protected List<InnerInterceptor> getPaginationBeforeInnerInterceptor() {
    List<InnerInterceptor> list = new ArrayList<>();
    Boolean isDataScope = databaseProperties.getIsDataScope();
    if (isDataScope) {
        list.add(new OptimisticLockerInnerInterceptor());
        list.add(new DataScopeInterceptor());
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) InnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor) OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) DataScopeInterceptor(com.albedo.java.plugins.database.mybatis.datascope.DataScopeInterceptor)

Example 10 with OptimisticLockerInnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor in project chao-cloud by chaojunzi.

the class MybatisPlusConfig method mybatisPlusInterceptor.

/**
 * mybatis-plus插件
 *
 * @return {@link MybatisPlusInterceptor}
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    // 设置sql的limit为无限制,默认是500
    PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor();
    pageInterceptor.setMaxLimit(-1L);
    interceptor.addInnerInterceptor(pageInterceptor);
    // 乐观锁插件
    OptimisticLockerInnerInterceptor lockerInnerInterceptor = new OptimisticLockerInnerInterceptor();
    interceptor.addInnerInterceptor(lockerInnerInterceptor);
    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) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) 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