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

export class GetProductsDto {
  @ApiProperty({ required: false, description: '品种分类' })
  @IsOptional()
  @IsString()
  category?: string;

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

  @ApiProperty({ required: false, default: 20, description: '每页数量' })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  size?: number = 20;
}

export class GetKlineDto {
  @ApiProperty({ description: '周期', enum: ['1m', '5m', '15m', '30m', '1h', '1d', '1w'] })
  @IsString()
  @IsEnum(['1m', '5m', '15m', '30m', '1h', '1d', '1w'])
  period: string;

  @ApiProperty({ required: false, default: 100, description: '返回条数' })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(1000)
  count?: number = 100;

  @ApiProperty({ required: false, description: '开始时间 (ISO8601)' })
  @IsOptional()
  @IsString()
  startTime?: string;

  @ApiProperty({ required: false, description: '结束时间 (ISO8601)' })
  @IsOptional()
  @IsString()
  endTime?: string;
}
