feat: add page size in all the rest API

This commit is contained in:
caturbgs
2021-12-22 15:23:05 +07:00
parent cdd6d39c90
commit c3df45dc9a
14 changed files with 135 additions and 124 deletions

View File

@@ -1,10 +1,4 @@
import {
forwardRef,
HttpException,
HttpStatus,
Inject,
Injectable,
} from '@nestjs/common';
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
import { Supplier } from '../entities/supplier.entity';
@@ -130,7 +124,7 @@ export class SupplierService {
return supplierData;
};
async findAllSupplier(page) {
async findAllSupplier(page, pageSize?) {
const baseQuery = this.supplierRepository
.createQueryBuilder('supplier')
.leftJoinAndMapOne(
@@ -148,8 +142,8 @@ export class SupplierService {
.select(['supplier', 'coa.amount', 'coa_undistribute.amount']);
const data = await baseQuery
.skip(page * 10)
.take(10)
.skip(page * (pageSize || 10))
.take(pageSize || 10)
.getMany();
const totalData = await baseQuery.getCount();