feat: implement partner licenses module with pagination and filtering capabilities
This commit is contained in:
@@ -7,7 +7,7 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
||||
export class PartnerActivatedLicensesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async findAll(partner_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(partner_id: string, page = 1, perPage = 10) {
|
||||
const defaultWhere: LicenseActivationWhereInput = {
|
||||
license: {
|
||||
charge_transaction: {
|
||||
@@ -15,11 +15,11 @@ export class PartnerActivatedLicensesService {
|
||||
},
|
||||
},
|
||||
}
|
||||
const [licenses, count] = await this.prisma.$transaction(async tx => [
|
||||
const [licenses, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.licenseActivation.findMany({
|
||||
where: defaultWhere,
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
select: {
|
||||
id: true,
|
||||
starts_at: true,
|
||||
@@ -71,8 +71,8 @@ export class PartnerActivatedLicensesService {
|
||||
|
||||
return ResponseMapper.paginate(mappedLicenses, {
|
||||
page,
|
||||
pageSize,
|
||||
count,
|
||||
perPage,
|
||||
total,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,18 +7,18 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
||||
export class PartnerAllocatedAccountsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async findAll(partner_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(partner_id: string, page = 1, perPage = 10) {
|
||||
const defaultWhere: PartnerAccountQuotaCreditWhereInput = {
|
||||
charge_transaction: {
|
||||
partner_id,
|
||||
},
|
||||
}
|
||||
|
||||
const [allocations, count] = await this.prisma.$transaction(async tx => [
|
||||
const [allocations, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.partnerAccountQuotaCredit.findMany({
|
||||
where: defaultWhere,
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
select: {
|
||||
id: true,
|
||||
created_at: true,
|
||||
@@ -54,8 +54,8 @@ export class PartnerAllocatedAccountsService {
|
||||
|
||||
return ResponseMapper.paginate(allocations, {
|
||||
page,
|
||||
pageSize,
|
||||
count,
|
||||
perPage,
|
||||
total,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -51,16 +51,16 @@ export class PartnerAccountChargeTransactionService {
|
||||
},
|
||||
}
|
||||
|
||||
async findAll(partner_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(partner_id: string, page = 1, perPage = 10) {
|
||||
const defaultWhere: PartnerAccountQuotaChargeTransactionWhereInput = {
|
||||
partner_id,
|
||||
}
|
||||
|
||||
const [transactions, count] = await this.prisma.$transaction(async tx => [
|
||||
const [transactions, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.partnerAccountQuotaChargeTransaction.findMany({
|
||||
where: defaultWhere,
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
select: this.defaultSelect,
|
||||
}),
|
||||
await tx.partnerAccountQuotaChargeTransaction.count({
|
||||
@@ -72,8 +72,8 @@ export class PartnerAccountChargeTransactionService {
|
||||
|
||||
return ResponseMapper.paginate(mappedTransactions, {
|
||||
page,
|
||||
pageSize,
|
||||
count,
|
||||
perPage,
|
||||
total,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -51,16 +51,16 @@ export class PartnerLicenseChargeTransactionService {
|
||||
},
|
||||
}
|
||||
|
||||
async findAll(partner_id: string, page = 1, pageSize = 10) {
|
||||
async findAll(partner_id: string, page = 1, perPage = 10) {
|
||||
const defaultWhere: LicenseChargeTransactionWhereInput = {
|
||||
partner_id,
|
||||
}
|
||||
|
||||
const [transactions, count] = await this.prisma.$transaction(async tx => [
|
||||
const [transactions, total] = await this.prisma.$transaction(async tx => [
|
||||
await tx.licenseChargeTransaction.findMany({
|
||||
where: defaultWhere,
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
select: this.defaultSelect,
|
||||
}),
|
||||
await tx.licenseChargeTransaction.count({
|
||||
@@ -72,8 +72,8 @@ export class PartnerLicenseChargeTransactionService {
|
||||
|
||||
return ResponseMapper.paginate(mappedTransactions, {
|
||||
page,
|
||||
pageSize,
|
||||
count,
|
||||
perPage,
|
||||
total,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user