From 86b19db4222fa50c040ba40444c632fb261627fc Mon Sep 17 00:00:00 2001 From: RogerLi Date: Fri, 14 Jun 2024 00:54:58 +0800 Subject: [PATCH] fix: pagination not correct --- src/dto/comment/getCommentsDto.ts | 2 +- src/dto/group/groupFilterDto.ts | 2 +- src/dto/order/orderFilterDto.ts | 4 ++-- src/dto/product/getProductDto.ts | 4 ++-- src/dto/ticket/getTicketsDto.ts | 4 ++-- src/vo/cart/getCartVo.ts | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dto/comment/getCommentsDto.ts b/src/dto/comment/getCommentsDto.ts index 0f6c65d..f9992ff 100644 --- a/src/dto/comment/getCommentsDto.ts +++ b/src/dto/comment/getCommentsDto.ts @@ -97,7 +97,7 @@ export class GetCommentsDTO { get options() { return { sort: this._sort, - skip: (this._page - 1) * this._limit, + page: this._page, limit: this._limit, }; } diff --git a/src/dto/group/groupFilterDto.ts b/src/dto/group/groupFilterDto.ts index cad7f1d..1efe041 100644 --- a/src/dto/group/groupFilterDto.ts +++ b/src/dto/group/groupFilterDto.ts @@ -45,7 +45,7 @@ export class GroupFilterDto { get options() { return { - skip: (this._page - 1) * this._limit, + page: this._page, limit: this._limit, sort: this._sort, }; diff --git a/src/dto/order/orderFilterDto.ts b/src/dto/order/orderFilterDto.ts index 92fe57f..992c0a0 100644 --- a/src/dto/order/orderFilterDto.ts +++ b/src/dto/order/orderFilterDto.ts @@ -75,8 +75,8 @@ export class OrderFilterDto { path: 'user', select: 'account name phone email', }, - skip: (this._page - 1) * this._limit, - ...(this._limit && { limit: this._limit }), + page: this._page, + limit: this._limit, sort: this._sort, }; } diff --git a/src/dto/product/getProductDto.ts b/src/dto/product/getProductDto.ts index df683d4..deb4238 100644 --- a/src/dto/product/getProductDto.ts +++ b/src/dto/product/getProductDto.ts @@ -123,8 +123,8 @@ export class GetProductDTO { } : { ...defaultProjection, recommendWeight: 0, isPublic: 0 }; return { - skip: (this._page - 1) * this._limit, - ...(this._limit && { limit: this._limit }), + page: this._page, + limit: this._limit, sort: this._sort, projection, }; diff --git a/src/dto/ticket/getTicketsDto.ts b/src/dto/ticket/getTicketsDto.ts index 5106a2d..8a5d3b7 100644 --- a/src/dto/ticket/getTicketsDto.ts +++ b/src/dto/ticket/getTicketsDto.ts @@ -128,8 +128,8 @@ export class GetTicketsDto { }; return { productSelect, - skip: (this._page - 1) * this._limit, - ...(this._limit && { limit: this._limit }), + page: this._page, + limit: this._limit, sort: this._sort, ticketSelect, }; diff --git a/src/vo/cart/getCartVo.ts b/src/vo/cart/getCartVo.ts index ade2640..3bd1344 100644 --- a/src/vo/cart/getCartVo.ts +++ b/src/vo/cart/getCartVo.ts @@ -12,7 +12,7 @@ export class GetCartVO { public readonly createdAt: Date; public readonly updatedAt: Date; - constructor(cart: ICartPagination | ICart, page: number, limit: number) { + constructor(cart: ICartPagination | ICart, limit: number, page: number) { this.createdAt = cart.createdAt; this.updatedAt = cart.updatedAt; this._id = cart._id;