From d8df50a68fc0e324e12d04f0d7b7f49cee79949c Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 19 Jan 2026 18:32:38 -0800 Subject: [PATCH] =?UTF-8?q?fix(c2c):=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E7=9A=84500=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 QueryC2cOrdersDto 和 QueryMyC2cOrdersDto 的 page/pageSize 字段添加 @Type(() => Number) 装饰器 - Query参数从URL获取时默认为字符串,需要显式转换为数字类型 - 添加 @IsInt() 验证确保参数为整数 - 修复 Prisma findMany take 参数期望 Int 但收到 String 的错误 Co-Authored-By: Claude Opus 4.5 --- .../trading-service/src/api/dto/c2c.dto.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/services/trading-service/src/api/dto/c2c.dto.ts b/backend/services/trading-service/src/api/dto/c2c.dto.ts index 5645027f..b3097387 100644 --- a/backend/services/trading-service/src/api/dto/c2c.dto.ts +++ b/backend/services/trading-service/src/api/dto/c2c.dto.ts @@ -1,5 +1,6 @@ -import { IsString, IsIn, IsOptional, IsNumberString } from 'class-validator'; +import { IsString, IsIn, IsOptional, IsNumberString, IsInt } from 'class-validator'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; // ==================== C2C 订单类型和状态 ==================== @@ -110,12 +111,16 @@ export class QueryC2cOrdersDto { @IsIn(['BUY', 'SELL']) type?: 'BUY' | 'SELL'; - @ApiPropertyOptional({ description: '页码' }) + @ApiPropertyOptional({ description: '页码', default: 1 }) @IsOptional() + @Type(() => Number) + @IsInt() page?: number; - @ApiPropertyOptional({ description: '每页数量' }) + @ApiPropertyOptional({ description: '每页数量', default: 20 }) @IsOptional() + @Type(() => Number) + @IsInt() pageSize?: number; } @@ -128,12 +133,16 @@ export class QueryMyC2cOrdersDto { @IsIn(['PENDING', 'MATCHED', 'PAID', 'COMPLETED', 'CANCELLED', 'EXPIRED']) status?: string; - @ApiPropertyOptional({ description: '页码' }) + @ApiPropertyOptional({ description: '页码', default: 1 }) @IsOptional() + @Type(() => Number) + @IsInt() page?: number; - @ApiPropertyOptional({ description: '每页数量' }) + @ApiPropertyOptional({ description: '每页数量', default: 20 }) @IsOptional() + @Type(() => Number) + @IsInt() pageSize?: number; }