fix(c2c): 修复分页参数类型转换问题导致的500错误
- 为 QueryC2cOrdersDto 和 QueryMyC2cOrdersDto 的 page/pageSize 字段添加 @Type(() => Number) 装饰器 - Query参数从URL获取时默认为字符串,需要显式转换为数字类型 - 添加 @IsInt() 验证确保参数为整数 - 修复 Prisma findMany take 参数期望 Int 但收到 String 的错误 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
63c192e90d
commit
d8df50a68f
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue