import { Controller, Post, Body } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { WalletApplicationService } from '@/application/services';
import { HandleDepositCommand } from '@/application/commands';
import { HandleDepositDTO } from '@/api/dto/request';
import { Public } from '@/shared/decorators';

@ApiTags('Deposit (Internal)')
@Controller('wallet/deposit')
export class DepositController {
  constructor(private readonly walletService: WalletApplicationService) {}

  @Post()
  @Public()
  @ApiOperation({
    summary: '处理充值入账',
    description: '内部服务调用,处理链上充值确认后的入账',
  })
  @ApiResponse({ status: 200, description: '入账成功' })
  async handleDeposit(@Body() dto: HandleDepositDTO): Promise<{ message: string }> {
    const command = new HandleDepositCommand(
      dto.accountSequence,
      dto.userId,
      dto.amount,
      dto.chainType,
      dto.txHash,
    );
    await this.walletService.handleDeposit(command);
    return { message: 'Deposit processed successfully' };
  }
}
