import { IsOptional, IsString, IsInt, IsBoolean, Min, Max, IsDateString, IsIn } from 'class-validator';
import { Transform, Type } from 'class-transformer';

/**
 * 用户列表查询 DTO
 */
export class ListUsersDto {
  @IsOptional()
  @IsString()
  keyword?: string;

  @IsOptional()
  @IsString()
  @IsIn(['ACTIVE', 'FROZEN', 'DEACTIVATED'])
  status?: string;

  @IsOptional()
  @IsString()
  @IsIn(['NOT_VERIFIED', 'PENDING', 'VERIFIED', 'REJECTED'])
  kycStatus?: string;

  @IsOptional()
  @Transform(({ value }) => value === 'true' || value === true)
  @IsBoolean()
  hasInviter?: boolean;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(0)
  minAdoptions?: number;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(0)
  maxAdoptions?: number;

  @IsOptional()
  @IsDateString()
  registeredAfter?: string;

  @IsOptional()
  @IsDateString()
  registeredBefore?: string;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1;

  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  pageSize?: number = 10;

  @IsOptional()
  @IsString()
  @IsIn(['registeredAt', 'personalAdoptionCount', 'teamAdoptionCount', 'leaderboardRank'])
  sortBy?: string = 'registeredAt';

  @IsOptional()
  @IsString()
  @IsIn(['asc', 'desc'])
  sortOrder?: 'asc' | 'desc' = 'desc';
}

/**
 * 获取用户详情 DTO
 */
export class GetUserDetailDto {
  @IsString()
  id!: string;  // 可以是 userId 或 accountSequence
}
