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

export enum ContestState {
  UNPUBLISHED = 'unpublished',
  PUBLISHED = 'published',
}

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

export enum UserRole {
  STUDENT = 'student',
  TEACHER = 'teacher',
  JUDGE = 'judge',
}

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

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

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

  @IsEnum(ContestState)
  @IsOptional()
  contestState?: ContestState;

  @IsEnum(ContestStatus)
  @IsOptional()
  status?: ContestStatus;

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

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

  @IsString()
  @IsOptional()
  stage?: string; // unpublished / registering / submitting / reviewing / finished

  @IsInt()
  @Type(() => Number)
  @IsOptional()
  creatorTenantId?: number; // 按创建活动的租户筛选

  @IsEnum(UserRole)
  @IsOptional()
  role?: UserRole;
}
