feat: 优化后台列表高度与分页容量
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
import { IsInt, IsOptional, Min } from 'class-validator';
|
||||
|
||||
export class PaginationDto {
|
||||
@ApiPropertyOptional({ description: '页码,从 1 开始', default: 1 })
|
||||
@@ -14,15 +14,15 @@ export class PaginationDto {
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(200)
|
||||
pageSize = 10;
|
||||
@Min(0)
|
||||
pageSize = 20;
|
||||
|
||||
get skip(): number {
|
||||
return (this.page - 1) * this.pageSize;
|
||||
}
|
||||
|
||||
get take(): number {
|
||||
get take(): number | undefined {
|
||||
if (this.pageSize === 0) return undefined;
|
||||
return this.pageSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PageResult } from '@artveris/shared';
|
||||
|
||||
export function buildPage<T>(list: T[], total: number, page: number, pageSize: number): PageResult<T> {
|
||||
return { list, total, page, pageSize };
|
||||
return { list, total, page: pageSize === 0 ? 1 : page, pageSize };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user