import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsOptional, IsEnum, IsBoolean, IsInt, Min, Max } from 'class-validator';
import { Transform, Type } from 'class-transformer';

export enum ContributionSourceTypeFilter {
  PERSONAL = 'PERSONAL',
  TEAM_LEVEL = 'TEAM_LEVEL',
  TEAM_BONUS = 'TEAM_BONUS',
}

export class GetContributionRecordsRequest {
  @ApiPropertyOptional({ enum: ContributionSourceTypeFilter, description: '来源类型筛选' })
  @IsOptional()
  @IsEnum(ContributionSourceTypeFilter)
  sourceType?: ContributionSourceTypeFilter;

  @ApiPropertyOptional({ description: '是否包含已过期记录', default: false })
  @IsOptional()
  @Transform(({ value }) => value === 'true' || value === true)
  @IsBoolean()
  includeExpired?: boolean = false;

  @ApiPropertyOptional({ description: '页码', default: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1;

  @ApiPropertyOptional({ description: '每页大小', default: 50 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  pageSize?: number = 50;
}
