feat: add page size in all the rest API
This commit is contained in:
@@ -3,24 +3,14 @@ import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
||||
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Transactions } from './entities/transactions.entity';
|
||||
import {
|
||||
Connection,
|
||||
EntityManager,
|
||||
EntityNotFoundError,
|
||||
Repository,
|
||||
} from 'typeorm';
|
||||
import { Connection, EntityNotFoundError, Repository } from 'typeorm';
|
||||
import { COA } from './entities/coa.entity';
|
||||
import { TransactionJournal } from './entities/transaction-journal.entity';
|
||||
import { CoaService } from './coa.service';
|
||||
import * as uuid from 'uuid';
|
||||
import { uniq } from 'lodash';
|
||||
import { Decimal } from 'decimal.js';
|
||||
import {
|
||||
balanceType,
|
||||
coaType,
|
||||
statusTransaction,
|
||||
typeTransaction,
|
||||
} from '../helper/enum-list';
|
||||
import { balanceType, coaType, statusTransaction, typeTransaction } from '../helper/enum-list';
|
||||
import { ProductService } from '../product/product.service';
|
||||
import { CreateJournalDto } from './dto/create-journal.dto';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
@@ -560,7 +550,11 @@ export class TransactionService {
|
||||
return transactionData;
|
||||
}
|
||||
|
||||
async transactionHistoryByUser(page: number, user: string) {
|
||||
async transactionHistoryByUser(
|
||||
page: number,
|
||||
user: string,
|
||||
pageSize?: number,
|
||||
) {
|
||||
const baseQuery = this.transactionRepository
|
||||
.createQueryBuilder('transaction')
|
||||
.select('transaction.id', 'id')
|
||||
@@ -578,8 +572,8 @@ export class TransactionService {
|
||||
// .leftJoinAndSelect('product_price.product', 'product');
|
||||
|
||||
const data = await baseQuery
|
||||
.skip(page * 10)
|
||||
.take(10)
|
||||
.offset(page * (pageSize || 10))
|
||||
.limit(pageSize || 10)
|
||||
.getRawMany();
|
||||
|
||||
const totalData = await baseQuery.getCount();
|
||||
@@ -614,10 +608,14 @@ export class TransactionService {
|
||||
}
|
||||
}
|
||||
|
||||
async getAllDepositReturnFromUser(user: string, page: number) {
|
||||
async getAllDepositReturnFromUser(
|
||||
user: string,
|
||||
page: number,
|
||||
pageSize?: number,
|
||||
) {
|
||||
return this.transactionRepository.findAndCount({
|
||||
skip: page * 10,
|
||||
take: 10,
|
||||
skip: page * (pageSize || 10),
|
||||
take: pageSize || 10,
|
||||
where: {
|
||||
user: user,
|
||||
type: typeTransaction.DEPOSIT_RETURN,
|
||||
@@ -628,10 +626,14 @@ export class TransactionService {
|
||||
});
|
||||
}
|
||||
|
||||
async getAllDepositReturnToUser(user: string, page: number) {
|
||||
async getAllDepositReturnToUser(
|
||||
user: string,
|
||||
page: number,
|
||||
pageSize?: number,
|
||||
) {
|
||||
return this.transactionRepository.findAndCount({
|
||||
skip: page * 10,
|
||||
take: 10,
|
||||
skip: page * (pageSize || 10),
|
||||
take: pageSize || 10,
|
||||
where: {
|
||||
user_destination: user,
|
||||
type: typeTransaction.DEPOSIT_RETURN,
|
||||
|
||||
Reference in New Issue
Block a user