import {
  IsString,
  IsOptional,
  IsArray,
  IsDateString,
  IsInt,
  ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';

export class AttachmentDto {
  @IsString()
  fileName: string;

  @IsString()
  fileUrl: string;

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

export class CreateHomeworkDto {
  @IsString()
  name: string;

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

  @IsDateString()
  submitStartTime: string;

  @IsDateString()
  submitEndTime: string;

  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => AttachmentDto)
  attachments?: AttachmentDto[];

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

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