import { ApiPropertyOptional } from '@nestjs/swagger'; import { IsOptional, IsEnum, IsDateString, IsUUID, IsNumber, Min, Max } from 'class-validator'; import { Type } from 'class-transformer'; import { TransactionType, PaymentMethod } from '../../../common/constants/categories'; export class QueryTransactionsDto { @ApiPropertyOptional({ description: 'Номер страницы', example: 1, default: 1, }) @IsOptional() @Type(() => Number) @IsNumber() @Min(1) page?: number = 1; @ApiPropertyOptional({ description: 'Количество записей на странице', example: 20, default: 20, }) @IsOptional() @Type(() => Number) @IsNumber() @Min(1) @Max(100) limit?: number = 20; @ApiPropertyOptional({ description: 'Фильтр по типу транзакции', enum: TransactionType, }) @IsOptional() @IsEnum(TransactionType) type?: TransactionType; @ApiPropertyOptional({ description: 'Фильтр по категории', example: '123e4567-e89b-12d3-a456-426614174000', }) @IsOptional() @IsUUID('4') categoryId?: string; @ApiPropertyOptional({ description: 'Фильтр по способу оплаты', enum: PaymentMethod, }) @IsOptional() @IsEnum(PaymentMethod) paymentMethod?: PaymentMethod; @ApiPropertyOptional({ description: 'Дата начала периода (YYYY-MM-DD)', example: '2024-01-01', }) @IsOptional() @IsDateString() startDate?: string; @ApiPropertyOptional({ description: 'Дата окончания периода (YYYY-MM-DD)', example: '2024-01-31', }) @IsOptional() @IsDateString() endDate?: string; @ApiPropertyOptional({ description: 'Поиск по описанию', example: 'продукты', }) @IsOptional() search?: string; @ApiPropertyOptional({ description: 'Сортировка', enum: ['date_asc', 'date_desc', 'amount_asc', 'amount_desc'], default: 'date_desc', }) @IsOptional() sort?: 'date_asc' | 'date_desc' | 'amount_asc' | 'amount_desc' = 'date_desc'; }