import { IsString, IsInt, IsEnum, IsOptional, IsArray, Min, Max, ValidateNested, IsNumber } from 'class-validator';
import { Type } from 'class-transformer';

export enum CalculationRule {
  AVERAGE = 'average',
  REMOVE_MAX_MIN = 'remove_max_min',
  REMOVE_MIN = 'remove_min',
}

/**
 * 评审维度
 */
export class ReviewDimensionDto {
  @IsString()
  name: string; // 维度名称

  @IsNumber()
  @Min(0)
  @Max(100)
  percentage: number; // 权重百分比（0-100）

  @IsString()
  @IsOptional()
  description?: string; // 评分标准说明
}

export class CreateReviewRuleDto {
  @IsString()
  ruleName: string;

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

  @IsInt()
  @Min(1)
  judgeCount: number;

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => ReviewDimensionDto)
  dimensions: ReviewDimensionDto[]; // 评审维度数组

  @IsEnum(CalculationRule)
  @IsOptional()
  calculationRule?: CalculationRule;
}

