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

/**
 * 推荐关系树查询参数
 */
export class ReferralTreeQueryDto {
  @IsOptional()
  @IsIn(['up', 'down', 'both'])
  direction?: 'up' | 'down' | 'both' = 'both';

  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  @IsInt()
  @Min(1)
  @Max(10)
  depth?: number = 1;
}

/**
 * 分类账查询参数
 */
export class LedgerQueryDto {
  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  @IsInt()
  @Min(1)
  page?: number = 1;

  @IsOptional()
  @Transform(({ value }) => parseInt(value, 10))
  @IsInt()
  @Min(1)
  @Max(100)
  pageSize?: number = 20;

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

  @IsOptional()
  @IsDateString()
  endDate?: string;
}

/**
 * 钱包分类账查询参数
 */
export class WalletLedgerQueryDto extends LedgerQueryDto {
  @IsOptional()
  @IsString()
  assetType?: string;

  @IsOptional()
  @IsString()
  entryType?: string;
}
