/**
 * [MOCK-005] BFF层证书服务
 * 通过环境变量自动切换Mock/真实服务
 * AI注意: 这是服务编排层，控制Mock/真实API切换
 * 
 * @module bff/services/certificateService
 * @author AI-Backend-Team
 * @created 2026-03-19
 */

import { CertificateService as RealCertificateService } from '../../services/CertificateService';
import { MockCertificateService } from '../mock/certificateMock';
import { logger } from '../../utils/logger';

// 环境变量控制
const useMock = process.env.USE_MOCK === 'true';

/**
 * 证书服务实例
 * 根据环境变量自动切换Mock/真实服务
 */
export const certificateService = useMock
  ? new MockCertificateService()
  : new RealCertificateService();

/**
 * Mock状态标记
 */
export const __MOCK__ = useMock;

/**
 * 当前服务类型
 */
export const __SERVICE_TYPE__ = useMock ? 'mock' : 'real';

// 启动日志
if (useMock) {
  logger.info('[BFF CertificateService] Running in MOCK mode');
} else {
  logger.info('[BFF CertificateService] Running in REAL mode');
}

// 类型导出，确保调用方类型安全
export type ICertificateService = typeof certificateService;
