import { IsString, IsNotEmpty, IsOptional, IsEmail, IsArray, IsInt, MinLength, Matches } from 'class-validator';

export class CreateTeacherDto {
  @IsString()
  @IsNotEmpty({ message: '姓名不能为空' })
  name: string;

  @IsString()
  @IsNotEmpty({ message: '手机号不能为空' })
  @Matches(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号' })
  phone: string;

  @IsOptional()
  @IsEmail({}, { message: '请输入正确的邮箱格式' })
  email?: string;

  @IsString()
  @IsNotEmpty({ message: '登录账号不能为空' })
  loginAccount: string;

  @IsOptional()
  @IsString()
  @MinLength(6, { message: '密码至少6位' })
  password?: string;

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

export class UpdateTeacherDto {
  @IsOptional()
  @IsString()
  @IsNotEmpty({ message: '姓名不能为空' })
  name?: string;

  @IsOptional()
  @IsString()
  @Matches(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号' })
  phone?: string;

  @IsOptional()
  @IsEmail({}, { message: '请输入正确的邮箱格式' })
  email?: string;

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