46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { IsOptional, IsString, IsBoolean, IsNumber, IsEnum } from 'class-validator';
|
|
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
import { CouponType } from '../interface/coupon';
|
|
|
|
export class FindCouponsDto {
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Type(() => Number)
|
|
@ApiPropertyOptional({ example: 1, description: 'Page number' })
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Type(() => Number)
|
|
@ApiPropertyOptional({ example: 10, description: 'Items per page' })
|
|
limit?: number;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@ApiPropertyOptional({ example: 'DISCOUNT', description: 'Search term for code or name' })
|
|
search?: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(CouponType)
|
|
@ApiPropertyOptional({ enum: CouponType, description: 'Filter by coupon type' })
|
|
type?: CouponType;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
@Type(() => Boolean)
|
|
@ApiPropertyOptional({ example: true, description: 'Filter by active status' })
|
|
isActive?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@ApiPropertyOptional({ example: 'createdAt', description: 'Field to order by' })
|
|
orderBy?: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(['asc', 'desc'])
|
|
@ApiPropertyOptional({ enum: ['asc', 'desc'], example: 'desc', description: 'Sort order' })
|
|
order?: 'asc' | 'desc';
|
|
}
|
|
|