import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { ArrayMinSize, IsArray, ValidateNested } from 'class-validator';
import { CreatePatientSurgeryDto } from './create-patient-surgery.dto.js';
import { UpdateSurgeryDeviceDto } from './update-surgery-device.dto.js';

export class UpdatePatientSurgeryDto extends CreatePatientSurgeryDto {
  @ApiProperty({
    description: '本次手术植入设备列表，编辑时需回传已有设备编号',
    type: [UpdateSurgeryDeviceDto],
  })
  @IsArray({ message: 'devices 必须是数组' })
  @ArrayMinSize(1, { message: 'devices 至少录入 1 个设备' })
  @ValidateNested({ each: true })
  @Type(() => UpdateSurgeryDeviceDto)
  declare devices: UpdateSurgeryDeviceDto[];
}
