feat: add page size in all the rest API
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user