import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsOptional } from 'class-validator';
import { EmptyStringToUndefined } from '../../common/transforms/empty-string-to-undefined.transform.js';
import { ToBoolean } from '../../common/transforms/to-boolean.transform.js';
import { DictionaryType } from '../../generated/prisma/enums.js';

/**
 * 字典查询 DTO：支持按类型筛选，并允许系统管理员查看停用项。
 */
export class DictionaryQueryDto {
  @ApiPropertyOptional({
    description: '字典类型，不传返回全部类型',
    enum: DictionaryType,
    example: DictionaryType.PRIMARY_DISEASE,
  })
  @IsOptional()
  @EmptyStringToUndefined()
  @IsEnum(DictionaryType, { message: 'type 枚举值不合法' })
  type?: DictionaryType;

  @ApiPropertyOptional({
    description: '是否包含停用项，仅系统管理员生效',
    example: true,
  })
  @IsOptional()
  @EmptyStringToUndefined()
  @ToBoolean()
  @IsBoolean({ message: 'includeDisabled 必须是布尔值' })
  includeDisabled?: boolean;
}
