| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | @Configuration |
| | | public class MyBatisPlusConfig { |
| | | |
| | | // 乐观锁插件 |
| | | @Bean |
| | | public OptimisticLockerInterceptor optimisticLockerInterceptor() { |
| | | return new OptimisticLockerInterceptor(); |
| | | } |
| | | |
| | | /** |
| | | * 开启批量添加 |
| | | * @return |
| | | */ |
| | | @Bean |
| | | public MySqlInjector sqlInjector() { |
| | | return new MySqlInjector(); |
| | | } |
| | | |
| | | /** |
| | | * 需要配置拦截器,不然在AddDevice中的total无法获取到 |
| | | * @return |
| | |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor(){ |
| | | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
| | | // 乐观锁 |
| | | interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); |
| | | // 分页配置 |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
| | | return interceptor; |
| | | } |