import {
  IsString,
  IsDateString,
  IsOptional,
  IsEnum,
  IsArray,
  IsInt,
  IsBoolean,
} from 'class-validator';

export enum ContestType {
  INDIVIDUAL = 'individual',
  TEAM = 'team',
}

export enum SubmitRule {
  ONCE = 'once',
  RESUBMIT = 'resubmit',
}

export enum ContestStatus {
  ONGOING = 'ongoing',
  FINISHED = 'finished',
}

export enum WorkType {
  IMAGE = 'image',
  VIDEO = 'video',
  DOCUMENT = 'document',
  CODE = 'code',
  OTHER = 'other',
}

export enum RegisterState {
  OPEN = 'open',
  CLOSED = 'closed',
}

export enum Visibility {
  PUBLIC = 'public',
  TARGETED = 'targeted',
  DESIGNATED = 'designated',
  INTERNAL = 'internal',
}

export class CreateContestDto {
  @IsString()
  contestName: string;

  @IsEnum(ContestType)
  contestType: ContestType;

  @IsEnum(Visibility)
  @IsOptional()
  visibility?: Visibility;

  @IsArray()
  @IsString({ each: true })
  @IsOptional()
  targetCities?: string[]; // 定向推送目标城市

  @IsInt()
  @IsOptional()
  ageMin?: number; // 最小年龄限制

  @IsInt()
  @IsOptional()
  ageMax?: number; // 最大年龄限制

  @IsDateString()
  startTime: string;

  @IsDateString()
  endTime: string;

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

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

  @IsArray()
  @IsInt({ each: true })
  @IsOptional()
  contestTenants?: number[];

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

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

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

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

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

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

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

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

  // 报名配置
  @IsDateString()
  registerStartTime: string;

  @IsDateString()
  registerEndTime: string;

  @IsEnum(RegisterState)
  @IsOptional()
  registerState?: RegisterState;

  @IsBoolean()
  @IsOptional()
  requireAudit?: boolean;

  @IsArray()
  @IsInt({ each: true })
  @IsOptional()
  allowedGrades?: number[];

  @IsArray()
  @IsInt({ each: true })
  @IsOptional()
  allowedClasses?: number[];

  @IsInt()
  @IsOptional()
  teamMinMembers?: number;

  @IsInt()
  @IsOptional()
  teamMaxMembers?: number;

  // 作品配置
  @IsEnum(SubmitRule)
  @IsOptional()
  submitRule?: SubmitRule;

  @IsDateString()
  submitStartTime: string;

  @IsDateString()
  submitEndTime: string;

  @IsEnum(WorkType)
  @IsOptional()
  workType?: WorkType;

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

  // 评审配置
  @IsInt()
  @IsOptional()
  reviewRuleId?: number;

  @IsDateString()
  reviewStartTime: string;

  @IsDateString()
  reviewEndTime: string;

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