import { ApiProperty } from '@nestjs/swagger'; export class ApiResponseDto { @ApiProperty({ description: '请求是否成功' }) success: boolean; @ApiProperty({ description: '响应数据', nullable: true }) data: T | null; @ApiProperty({ description: '错误信息', nullable: true }) message: string | null; @ApiProperty({ description: '响应时间戳' }) timestamp: Date; constructor(success: boolean, data: T | null, message: string | null = null) { this.success = success; this.data = data; this.message = message; this.timestamp = new Date(); } static success(data: T): ApiResponseDto { return new ApiResponseDto(true, data, null); } static error(message: string): ApiResponseDto { return new ApiResponseDto(false, null, message); } }