package com.wms_main.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * mp配置类
 */
@SpringBootConfiguration
@MapperScan("com.wms_main.mapper")
@EnableTransactionManagement
public class MybatisPlusConfig {
    /**
     * 分页插件的控制
     * @return MybatisPlusInterceptor
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 添加分页插件
        PaginationInnerInterceptor pageInnerInterceptor = new PaginationInnerInterceptor();
        pageInnerInterceptor.setDbType(DbType.MYSQL);
        pageInnerInterceptor.setMaxLimit(1000L);
        interceptor.addInnerInterceptor(pageInnerInterceptor);
        return interceptor;
    }
}
