feat: implement partner licenses module with pagination and filtering capabilities
This commit is contained in:
@@ -60,19 +60,19 @@ export class consumerCustomersService {
|
||||
}
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string, page = 1, pageSize = 10) {
|
||||
const [customers, count] = await this.prisma.$transaction(async tx => [
|
||||
async findAll(consumer_id: string, page = 1, perPage = 10) {
|
||||
const [customers, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.customer.findMany({
|
||||
where: this.defaultWhere(consumer_id),
|
||||
select: this.defaultSelect,
|
||||
skip: (page - 1) * pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: 10,
|
||||
}),
|
||||
await tx.customer.count({
|
||||
where: this.defaultWhere(consumer_id),
|
||||
}),
|
||||
])
|
||||
return ResponseMapper.paginate(customers, { count, page, pageSize })
|
||||
return ResponseMapper.paginate(customers, { total, page, perPage })
|
||||
}
|
||||
|
||||
async findOne(consumer_id: string, customer_id: string) {
|
||||
|
||||
@@ -50,7 +50,7 @@ export class CustomerSaleInvoicesService {
|
||||
created_at: true,
|
||||
}
|
||||
|
||||
async findAll(consumer_id: string, customer_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(consumer_id: string, customer_id: string, page = 1, perPage = 10) {
|
||||
const salesWhere: SalesInvoiceWhereInput = {
|
||||
customer_id,
|
||||
pos: {
|
||||
@@ -62,7 +62,7 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
}
|
||||
|
||||
const [accounts, count] = await this.prisma.$transaction(async tx => [
|
||||
const [accounts, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.salesInvoice.findMany({
|
||||
where: salesWhere,
|
||||
select: {
|
||||
@@ -73,7 +73,7 @@ export class CustomerSaleInvoicesService {
|
||||
},
|
||||
},
|
||||
},
|
||||
skip: (page - 1) * pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: 10,
|
||||
}),
|
||||
await tx.salesInvoice.count({
|
||||
@@ -90,9 +90,9 @@ export class CustomerSaleInvoicesService {
|
||||
})
|
||||
|
||||
return ResponseMapper.paginate(mappedAccounts, {
|
||||
count,
|
||||
total,
|
||||
page,
|
||||
pageSize,
|
||||
perPage,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user