bw-mini-app-server/src/dto/common-response.dto.ts

49 lines
1.1 KiB
TypeScript

import { ApiProperty, ApiHideProperty } from '@nestjs/swagger';
export class CommonResponseDto {
@ApiProperty({ description: '响应状态码', example: 200 })
code: number;
@ApiProperty({ description: '响应消息', example: 'success' })
message: string;
@ApiHideProperty()
data: any;
@ApiProperty({ description: '时间戳', example: 1703001000000 })
timestamp: number;
@ApiProperty({ description: '追踪ID', example: 'trace-uuid-123' })
traceId: string;
}
export class PaginationDto {
@ApiProperty({ description: '页码', example: 1, minimum: 1 })
page: number;
@ApiProperty({
description: '每页数量',
example: 10,
minimum: 1,
maximum: 100,
})
limit: number;
}
export class PaginationResponseDto {
@ApiHideProperty()
items: any[];
@ApiProperty({ description: '总数量', example: 100 })
total: number;
@ApiProperty({ description: '当前页码', example: 1 })
page: number;
@ApiProperty({ description: '每页数量', example: 10 })
limit: number;
@ApiProperty({ description: '总页数', example: 10 })
totalPages: number;
}