import { Type, Transform } from 'class-transformer' import { IsBoolean, IsIn, IsInt, IsNotEmpty, IsOptional, IsString, IsUrl, Matches, Max, MaxLength, Min, } from 'class-validator' export class ProductDto { @IsString() @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value)) @IsNotEmpty() @MaxLength(80) title!: string @IsString() @MaxLength(5000) description!: string @IsUrl({ protocols: ['https'], require_protocol: true }) @MaxLength(1000) coverUrl!: string @IsInt() @Min(1) @Max(10000000) price!: number @IsBoolean() isActive!: boolean @IsInt() @Min(0) @Max(99999) sortOrder!: number @IsOptional() @IsInt() @Min(0) version?: number } export class StockDto { @IsInt() @Min(-1000000) @Max(1000000) delta!: number @IsInt() @Min(0) version!: number @IsString() @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value)) @IsNotEmpty() @MaxLength(200) reason!: string } export class BuyProductDto { @IsInt() @Min(1) @Max(10000000) expectedPrice!: number @IsString() @IsNotEmpty() @MaxLength(50) productId!: string @IsString() @Matches(/^[a-zA-Z0-9_-]{8,80}$/) requestId!: string @IsInt() @Min(1) @Max(99) quantity!: number @IsString() @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value)) @IsNotEmpty() @MaxLength(40) contactName!: string @IsString() @Matches(/^1[3-9]\d{9}$/) contactPhone!: string } export class ShopQueryDto { @IsOptional() @Type(() => Number) @IsInt() @Min(1) @Max(100000) page = 1 @IsOptional() @Type(() => Number) @IsInt() @Min(1) @Max(50) limit = 20 @IsOptional() @IsIn(['PENDING', 'PAID', 'COMPLETED', 'CANCELLED']) status?: | 'PENDING' | 'PAID' | 'COMPLETED' | 'CANCELLED' @IsOptional() @IsString() @MaxLength(80) search?: string @IsOptional() @IsString() @MaxLength(50) productId?: string }