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

export enum RecordType {
  STUDENT = 'STUDENT',
  CLASS = 'CLASS',
}

export class CreateGrowthRecordDto {
  @IsInt()
  @IsNotEmpty({ message: '学生ID不能为空' })
  studentId: number;

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

  @IsEnum(RecordType)
  recordType: RecordType;

  @IsString()
  @IsNotEmpty({ message: '标题不能为空' })
  title: string;

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

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  images?: string[];

  @IsDateString()
  recordDate: string;
}

export class UpdateGrowthRecordDto {
  @IsOptional()
  @IsString()
  @IsNotEmpty({ message: '标题不能为空' })
  title?: string;

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

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  images?: string[];

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

export class QueryGrowthRecordDto {
  @IsOptional()
  @IsInt()
  page?: number;

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

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

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

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

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