package com.lingyue.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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MyBatis Plus 统一配置
 * 单体应用使用，扫描所有服务的 Mapper
 * 
 * @author lingyue
 * @since 2.0.0
 */
@Configuration
@MapperScan({
    "com.lingyue.auth.repository",
    "com.lingyue.document.repository",
    "com.lingyue.parse.repository",
    "com.lingyue.ai.repository",
    "com.lingyue.graph.repository",
    "com.lingyue.notification.repository"
})
public class MyBatisPlusConfig {
    
    /**
     * 分页插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // PostgreSQL 分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
        return interceptor;
    }
}
