import {
  IsString,
  IsOptional,
  IsBoolean,
  IsInt,
  IsObject,
  Min,
  Max,
  ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { RuleConditions } from '../../../domain/entities/classification-rule.entity';

/**
 * 创建分类规则
 */
export class CreateRuleDto {
  @IsString()
  name: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsObject()
  conditions: RuleConditions;
}

/**
 * 更新分类规则
 */
export class UpdateRuleDto {
  @IsOptional()
  @IsString()
  name?: string;

  @IsOptional()
  @IsString()
  description?: string | null;

  @IsOptional()
  @IsObject()
  conditions?: RuleConditions;

  @IsOptional()
  @IsBoolean()
  isEnabled?: boolean;
}

/**
 * 查询规则列表
 */
export class ListRulesDto {
  @IsOptional()
  @IsBoolean()
  isEnabled?: boolean;

  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(100)
  limit?: number;

  @IsOptional()
  @IsInt()
  @Min(0)
  offset?: number;
}

/**
 * 测试规则
 */
export class TestRuleDto {
  @IsString()
  accountSequence: string;
}

/**
 * 预估规则匹配用户数
 */
export class EstimateRuleDto {
  @IsObject()
  conditions: RuleConditions;
}
