import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsString,
  IsEnum,
  IsDateString,
  IsOptional,
  IsObject,
  IsArray,
} from 'class-validator';
import { ReportPeriod, ReportDimension } from '../../../domain/value-objects';

export class GenerateReportDto {
  @ApiProperty({ description: '报表代码', example: 'RPT_LEADERBOARD' })
  @IsString()
  reportCode: string;

  @ApiProperty({
    description: '报表周期',
    enum: ReportPeriod,
    example: ReportPeriod.DAILY,
  })
  @IsEnum(ReportPeriod)
  reportPeriod: ReportPeriod;

  @ApiProperty({ description: '开始日期', example: '2024-01-01' })
  @IsDateString()
  startDate: string;

  @ApiProperty({ description: '结束日期', example: '2024-01-31' })
  @IsDateString()
  endDate: string;

  @ApiPropertyOptional({
    description: '报表维度',
    enum: ReportDimension,
    isArray: true,
  })
  @IsOptional()
  @IsArray()
  @IsEnum(ReportDimension, { each: true })
  dimensions?: ReportDimension[];

  @ApiPropertyOptional({ description: '筛选条件' })
  @IsOptional()
  @IsObject()
  filters?: Record<string, any>;
}
