Files
MinglarBackendNestJS/src/modules/prepopulate/services/prepopulate.service.ts

85 lines
2.4 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import { PrismaService } from '../../../common/database/prisma.service';
@Injectable()
export class PrePopulateService {
constructor(private prisma: PrismaService) {}
async getAllBankDetails() {
return await this.prisma.banks.findMany({
where: {
isActive: true,
deletedAt: null,
},
include: {
BankBranches: {
select: {
id: true,
branchAddress: true,
ifscCode: true,
},
},
},
});
}
async getAllCurrencyDetails() {
return await this.prisma.currencies.findMany({
where: {
isActive: true,
deletedAt: null,
},
});
}
async getAllPQQQuesAndAns() {
return await this.prisma.pQQCategories.findMany({
where: { isActive: true },
include: {
pqqsubCategories: {
include: {
questions: {
include: {
PQQAnswers: {
orderBy: {
displayOrder: 'asc'
}
}
},
orderBy: {
displayOrder: 'asc'
}
}
},
orderBy: { displayOrder: 'asc' }
}
},
orderBy: { displayOrder: 'asc' }
});
}
async getAllDocumentTypeWithCountryStateCity() {
const [documentDetails, countryDetails, stateDetails, cityDetails] =
await this.prisma.$transaction([
this.prisma.documentType.findMany({
where: { isActive: true, isVisible: true },
orderBy: { displayOrder: 'asc' }
}),
this.prisma.countries.findMany({
where: { isActive: true },
}),
this.prisma.states.findMany({
where: { isActive: true }
}),
this.prisma.cities.findMany({
where: { isActive: true }
})
]);
return { documentDetails, countryDetails, stateDetails, cityDetails };
}
}