Search in sources :

Example 6 with InnerInterceptor

use of com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor in project lamp-job by zuihou.

the class BaseExecutorMybatisAutoConfiguration method getPaginationBeforeInnerInterceptor.

/**
 * 数据权限插件
 *
 * @return 数据权限插件
 */
@Override
protected List<InnerInterceptor> getPaginationBeforeInnerInterceptor() {
    List<InnerInterceptor> list = new ArrayList<>();
    Boolean isDataScope = databaseProperties.getIsDataScope();
    if (isDataScope) {
        list.add(new DataScopeInnerInterceptor(userId -> SpringUtils.getBean(UserService.class).getDataScopeById(userId)));
    }
    return list;
}
Also used : Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) DataScopeInnerInterceptor(top.tangyh.basic.database.mybatis.auth.DataScopeInnerInterceptor) UserService(top.tangyh.lamp.authority.service.auth.UserService) BaseMybatisConfiguration(top.tangyh.basic.database.datasource.BaseMybatisConfiguration) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) InnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor) SpringUtils(top.tangyh.basic.utils.SpringUtils) DatabaseProperties(top.tangyh.basic.database.properties.DatabaseProperties) ArrayList(java.util.ArrayList) DataScopeInnerInterceptor(top.tangyh.basic.database.mybatis.auth.DataScopeInnerInterceptor) UserService(top.tangyh.lamp.authority.service.auth.UserService) ArrayList(java.util.ArrayList) DataScopeInnerInterceptor(top.tangyh.basic.database.mybatis.auth.DataScopeInnerInterceptor) InnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor)

Example 7 with InnerInterceptor

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

InnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor)7 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)4 BlockAttackInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor)4 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)4 Bean (org.springframework.context.annotation.Bean)4 OptimisticLockerInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor)3 ArrayList (java.util.ArrayList)3 IllegalSQLInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor)2 List (java.util.List)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Expression (net.sf.jsqlparser.expression.Expression)2 StringValue (net.sf.jsqlparser.expression.StringValue)2 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)2 Configuration (org.springframework.context.annotation.Configuration)2 Order (org.springframework.core.annotation.Order)2 BaseMybatisConfiguration (top.tangyh.basic.database.datasource.BaseMybatisConfiguration)2 DataScopeInnerInterceptor (top.tangyh.basic.database.mybatis.auth.DataScopeInnerInterceptor)2 DatabaseProperties (top.tangyh.basic.database.properties.DatabaseProperties)2