| | |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; |
| | | import com.ruoyi.common.handler.CustomTenantLineHandler; |
| | | import com.ruoyi.common.interceptor.DataScopeSqlInterceptor; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.mapping.BoundSql; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.session.ResultHandler; |
| | | import org.apache.ibatis.session.RowBounds; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | |
| | | */ |
| | | @EnableTransactionManagement(proxyTargetClass = true) |
| | | @Configuration |
| | | public class MybatisPlusConfig |
| | | { |
| | | public class MybatisPlusConfig { |
| | | |
| | | @Autowired |
| | | private DataScopeSqlInterceptor dataScopeSqlInterceptor; |
| | | |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() |
| | | { |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | // 租户插件 |
| | | TenantLineInnerInterceptor tenantLineInnerInterceptor = new TenantLineInnerInterceptor(new CustomTenantLineHandler()); |
| | | interceptor.addInnerInterceptor(tenantLineInnerInterceptor); |
| | | // TenantLineInnerInterceptor tenantLineInnerInterceptor = new TenantLineInnerInterceptor(new CustomTenantLineHandler()); |
| | | // interceptor.addInnerInterceptor(tenantLineInnerInterceptor); |
| | | // 分页插件 |
| | | interceptor.addInnerInterceptor(paginationInnerInterceptor()); |
| | | // 乐观锁插件 |
| | | interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); |
| | | // 阻断插件 |
| | | interceptor.addInnerInterceptor(blockAttackInnerInterceptor()); |
| | | // 数据权限插件 |
| | | interceptor.addInnerInterceptor(dataScopeSqlInterceptor); |
| | | return interceptor; |
| | | } |
| | | |