yangys
2025-11-14 fca5c28c79b061f4db3658f6d9e043024f326962
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.qianwen.mdc.collect.config;
 
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
 
@Configuration
public class MybatisPlusConfig {
    //@Value("${dbType}")
    private String dbType;
    /**
     * 根据配置获取数据库类型枚举值
     * @return
     */
    private DbType getMybatisPlusDbType() {
        return DbType.getDbType(dbType);
    }
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
       
        /*
        DbType dtype = this.getMybatisPlusDbType();
        if(dtype != DbType.MYSQL && dtype != DbType.ORACLE) {//稍后开发oracle的mapper来支持
        if(dtype != DbType.MYSQL && dtype != DbType.ORACLE) {    
            throw new java.lang.IllegalStateException("不支持的dbType:"+dtype);
        }
        */
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
 
}