import { Controller, Get } from '@nestjs/common';
import { PlanRepository } from '../../../infrastructure/repositories/plan.repository';

@Controller('api/v1/billing/plans')
export class PlanController {
  constructor(private readonly planRepo: PlanRepository) {}

  @Get()
  async findAll() {
    const plans = await this.planRepo.findAll();
    return plans.map((p) => ({
      id: p.id,
      name: p.name,
      displayName: p.displayName,
      monthlyPriceUsd: p.monthlyPriceCentsUsd / 100,
      monthlyPriceCny: p.monthlyPriceFenCny / 100,
      includedTokensPerMonth: p.includedTokens,
      overageRateUsdPerMToken: p.overageRateCentsPerMTokenUsd / 100,
      overageRateCnyPerMToken: p.overageRateFenPerMTokenCny / 100,
      maxServers: p.maxServers,
      maxUsers: p.maxUsers,
      maxStandingOrders: p.maxStandingOrders,
      hardLimitPercent: p.hardLimitPercent,
      trialDays: p.trialDays,
    }));
  }
}
