31 lines
808 B
TypeScript
31 lines
808 B
TypeScript
import { Transform } from 'class-transformer';
|
|
import { Min, IsNumber, IsOptional } from 'class-validator';
|
|
import { toNumber } from 'lodash';
|
|
|
|
import { DtoValidation } from '@/modules/core/decorator/dto.validation.decorator';
|
|
import { PaginateOptions } from '@/modules/database/types';
|
|
|
|
/**
|
|
* 分页数据查询验证
|
|
*/
|
|
@DtoValidation({ type: 'query' })
|
|
export class PaginateDto implements PaginateOptions {
|
|
/**
|
|
* 当前页
|
|
*/
|
|
@Transform(({ value }) => toNumber(value))
|
|
@Min(1, { message: '当前页必须大于1' })
|
|
@IsNumber()
|
|
@IsOptional()
|
|
page?: number = 1;
|
|
|
|
/**
|
|
* 每页数据量
|
|
*/
|
|
@Transform(({ value }) => toNumber(value))
|
|
@Min(1, { message: '每页显示数据必须大于1' })
|
|
@IsNumber()
|
|
@IsOptional()
|
|
limit?: number = 10;
|
|
}
|