import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiParam, ApiSecurity } from '@nestjs/swagger';
import { ApiKeyGuard } from '../../common/guards/api-key.guard';
import { RequireApiTier } from '../../common/decorators/api-tier.decorator';
import { CouponService } from './coupon.service';

@ApiTags('coupon')
@ApiSecurity('api-key')
@Controller('v1/coupon')
@UseGuards(ApiKeyGuard)
export class CouponController {
  constructor(private readonly couponService: CouponService) {}

  @Get(':tokenId')
  @RequireApiTier('public')
  @ApiOperation({ summary: '查询券详情（面值/类型/到期/转售次数）' })
  @ApiParam({ name: 'tokenId', description: '券 Token ID' })
  getCouponDetail(@Param('tokenId') tokenId: string) {
    return this.couponService.getCouponDetail(BigInt(tokenId));
  }

  @Get('batch/:batchId/holders')
  @RequireApiTier('institutional')
  @ApiOperation({ summary: '查询某批次券的当前持有人列表（机构API）' })
  @ApiParam({ name: 'batchId', description: '批次 ID' })
  getBatchHolders(@Param('batchId') batchId: string) {
    return this.couponService.getBatchHolders(BigInt(batchId));
  }
}
