import { ApiHideProperty } from '@nestjs/swagger';

/**
 * 基础 DTO 工具类型
 */

// 排除系统自动管理的字段
export type OmitSystemFields<T> = Omit<T, 'id' | 'createdAt' | 'updatedAt'>;

// 排除关联字段（通常在 service 层设置）
export type OmitRelationFields<T, K extends keyof T> = Omit<T, K>;

// 创建 DTO 基础类型
export type CreateDtoBase<T, K extends keyof T = never> = OmitSystemFields<
  OmitRelationFields<T, K>
>;

// 更新 DTO 基础类型
export type UpdateDtoBase<T, K extends keyof T = never> = Partial<CreateDtoBase<T, K>>;

/**
 * 用于隐藏不应该暴露给客户端的字段
 */
export abstract class BaseDto {
  @ApiHideProperty()
  id?: string;

  @ApiHideProperty()
  createdAt?: Date;

  @ApiHideProperty()
  updatedAt?: Date;
}