import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { PaymentORM } from '../infrastructure/database/postgres/entities/payment.orm';
import { PaymentPostgresRepository } from '../adapters/outbound/persistence/payment-postgres.repository';
import { PAYMENT_REPOSITORY } from '../domain/repositories/payment.repository.interface';
import { OrderModule } from '../order/order.module';
import { PaymentService } from '../application/services/payment.service';
import { PaymentController } from '../adapters/inbound/payment.controller';
import { AlipayAdapter } from '../adapters/outbound/payment-methods/alipay.adapter';
import { WechatPayAdapter } from '../adapters/outbound/payment-methods/wechat-pay.adapter';
import { StripeAdapter } from '../adapters/outbound/payment-methods/stripe.adapter';
import { TransactionService } from '../infrastructure/database/transaction.service';

@Module({
  imports: [
    TypeOrmModule.forFeature([PaymentORM]),
    OrderModule,
  ],
  controllers: [PaymentController],
  providers: [
    PaymentService,
    TransactionService,
    {
      provide: PAYMENT_REPOSITORY,
      useClass: PaymentPostgresRepository,
    },
    AlipayAdapter,
    WechatPayAdapter,
    StripeAdapter,
  ],
  exports: [PaymentService, PAYMENT_REPOSITORY, TransactionService],
})
export class PaymentModule {}
