package com.malk.pro;

import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.persistence.EntityManager;

/**
 * mjava-pro 启动类
 *
 * <p>多客户单部署模式。请求带 {@code X-Tenant-Id} 从宜搭应用表动态加载租户配置。</p>
 *
 * <p>基座扫描 {@code com.malk}：</p>
 * <ul>
 *   <li>复用 mjava 基座所有 Client / Service / UtilHttp / UtilToken / TraceIdFilter</li>
 *   <li>复用 AuthFilter / AuthInterceptor（可通过 mjava.auth.enabled 开启）</li>
 *   <li>新增 TenantContext / TenantInterceptor 做租户隔离</li>
 * </ul>
 *
 * <p>默认端口 9010，context-path {@code /api/pro}。</p>
 */
@EnableJpaAuditing
@EnableScheduling
@SpringBootApplication(scanBasePackages = {"com.malk"})
public class Boot {

    public static void main(String... args) {
        SpringApplication.run(Boot.class, args);
    }

    @Bean
    public JPAQueryFactory jpaQueryFactory(EntityManager entityManager) {
        return new JPAQueryFactory(entityManager);
    }
}
