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

export class CreateScheduleDto {
  @IsInt()
  @IsNotEmpty()
  classId: number;

  @IsInt()
  @IsNotEmpty()
  courseId: number;

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

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

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

  @IsOptional()
  @IsInt()
  @Min(0)
  @Max(6)
  weekDay?: number;

  @IsEnum(['NONE', 'DAILY', 'WEEKLY'])
  repeatType: string;

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

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

export class UpdateScheduleDto {
  @IsOptional()
  @IsInt()
  teacherId?: number;

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

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

  @IsOptional()
  @IsInt()
  @Min(0)
  @Max(6)
  weekDay?: number;

  @IsOptional()
  @IsEnum(['NONE', 'DAILY', 'WEEKLY'])
  repeatType?: string;

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

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

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

export class QueryScheduleDto {
  @IsOptional()
  @IsInt()
  classId?: number;

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

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

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

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

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

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

  @IsOptional()
  @IsInt()
  @Min(1)
  page?: number;

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

export class TimetableQueryDto {
  @IsNotEmpty()
  @IsDateString()
  startDate: string;

  @IsNotEmpty()
  @IsDateString()
  endDate: string;

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

  @IsOptional()
  @IsInt()
  teacherId?: number;
}

export class BatchScheduleItemDto {
  @IsInt()
  @IsNotEmpty()
  classId: number;

  @IsInt()
  @IsNotEmpty()
  courseId: number;

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

  @IsDateString()
  @IsNotEmpty()
  scheduledDate: string;

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

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

export class BatchCreateScheduleDto {
  @IsNotEmpty()
  schedules: BatchScheduleItemDto[];
}
