import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { DeviceStatus } from '../../generated/prisma/enums.js';
import { Type } from 'class-transformer';
import { IsEnum, IsInt, IsOptional, Min } from 'class-validator';

/**
 * 创建设备 DTO。
 */
export class CreateDeviceDto {
  @ApiPropertyOptional({
    description: '设备状态，默认 ACTIVE',
    enum: DeviceStatus,
    example: DeviceStatus.ACTIVE,
  })
  @IsOptional()
  @IsEnum(DeviceStatus, { message: 'status 枚举值不合法' })
  status?: DeviceStatus;

  @ApiProperty({ description: '归属患者 ID', example: 1 })
  @Type(() => Number)
  @IsInt({ message: 'patientId 必须是整数' })
  @Min(1, { message: 'patientId 必须大于 0' })
  patientId!: number;
}
