feat(diet-records): 修复营养成分分析记录查询参数验证和类型转换
修复GET请求查询参数验证装饰器缺失问题,添加正确的class-validator装饰器 在控制器中实现查询参数类型转换,确保数字参数正确处理 更新技术文档,添加DTO验证装饰器编写规范和GET请求参数处理指南
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsOptional, IsDateString, IsNumber, IsString } from 'class-validator';
|
||||
import { ApiResponseDto } from '../../base.dto';
|
||||
|
||||
/**
|
||||
@@ -98,17 +99,27 @@ export class NutritionAnalysisRecordsResponseDto extends ApiResponseDto<{
|
||||
*/
|
||||
export class GetNutritionAnalysisRecordsQueryDto {
|
||||
@ApiProperty({ description: '页码', example: 1, required: false })
|
||||
page?: number;
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
page?: string;
|
||||
|
||||
@ApiProperty({ description: '每页数量', example: 20, required: false })
|
||||
limit?: number;
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
limit?: string;
|
||||
|
||||
@ApiProperty({ description: '开始日期', example: '2023-01-01', required: false })
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
startDate?: string;
|
||||
|
||||
@ApiProperty({ description: '结束日期', example: '2023-12-31', required: false })
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
endDate?: string;
|
||||
|
||||
@ApiProperty({ description: '分析状态', example: 'success', required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user