203 lines
4.9 KiB
TypeScript
203 lines
4.9 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { PrismaClient } from '@prisma/client';
|
|
@Injectable()
|
|
export class PrePopulateService {
|
|
constructor(private prisma: PrismaClient) { }
|
|
|
|
async getAllBankDetails() {
|
|
return await this.prisma.banks.findMany({
|
|
where: {
|
|
isActive: true,
|
|
deletedAt: null,
|
|
},
|
|
select: {
|
|
id: true,
|
|
bankName: true,
|
|
},
|
|
orderBy: { bankName: 'asc' }
|
|
});
|
|
}
|
|
|
|
async getBankBranchesByBankId(bankXid: number) {
|
|
return await this.prisma.bankBranches.findMany({
|
|
where: {
|
|
bankXid,
|
|
isActive: true,
|
|
},
|
|
select: {
|
|
id: true,
|
|
branchAddress: true,
|
|
ifscCode: true,
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
async getCityByStateId(stateXid: number) {
|
|
return await this.prisma.cities.findMany({
|
|
where: {
|
|
stateXid,
|
|
isActive: true,
|
|
deletedAt: null
|
|
},
|
|
select: {
|
|
id: true,
|
|
cityName: true,
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
async getAllCurrencyDetails() {
|
|
return await this.prisma.currencies.findMany({
|
|
where: {
|
|
isActive: true,
|
|
deletedAt: null,
|
|
},
|
|
select: {
|
|
id: true,
|
|
currencyName: true,
|
|
currencySymbol: true,
|
|
},
|
|
orderBy: { currencyName: 'asc' }
|
|
});
|
|
}
|
|
|
|
async getAllPQQQuesAndAns() {
|
|
return await this.prisma.pQQCategories.findMany({
|
|
where: { isActive: true },
|
|
select: {
|
|
id: true,
|
|
categoryName: true,
|
|
displayOrder: true,
|
|
pqqsubCategories: {
|
|
where: { isActive: true },
|
|
select: {
|
|
id: true,
|
|
subCategoryName: true,
|
|
categoryXid: true,
|
|
displayOrder: true,
|
|
questions: {
|
|
where: { isActive: true },
|
|
select: {
|
|
id: true,
|
|
questionName: true,
|
|
maxPoints: true,
|
|
displayOrder: true,
|
|
PQQAnswers: {
|
|
where: { isActive: true },
|
|
orderBy: { displayOrder: 'asc' },
|
|
select: {
|
|
id: true,
|
|
answerName: true,
|
|
answerPoints: true,
|
|
displayOrder: true
|
|
}
|
|
}
|
|
},
|
|
orderBy: { displayOrder: 'asc' }
|
|
},
|
|
},
|
|
orderBy: { displayOrder: 'asc' },
|
|
},
|
|
},
|
|
orderBy: { displayOrder: 'asc' },
|
|
});
|
|
}
|
|
|
|
|
|
async getAllDocumentTypeWithCountryStateCity() {
|
|
const [documentDetails, countryDetails, stateDetails, companyTypeDetails] =
|
|
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 },
|
|
orderBy: { stateName: 'asc' }
|
|
}),
|
|
this.prisma.companyTypes.findMany({
|
|
where: { isActive: true },
|
|
orderBy: { companyTypeName: 'asc' }
|
|
}),
|
|
]);
|
|
|
|
return { documentDetails, countryDetails, stateDetails, companyTypeDetails };
|
|
}
|
|
|
|
async getAllFrequencies() {
|
|
return await this.prisma.frequencies.findMany({
|
|
where: {
|
|
isActive: true,
|
|
deletedAt: null,
|
|
},
|
|
select: {
|
|
id: true,
|
|
frequencyName: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
async getAllPrePopulateDataForAddActivity() {
|
|
const [
|
|
foodType,
|
|
cuisineDetails,
|
|
vehicleType,
|
|
navigationMode,
|
|
taxDetails,
|
|
energyLevel,
|
|
aminitiesDetails,
|
|
allowedEntryType,
|
|
ageRestrictionDetails
|
|
] =
|
|
await this.prisma.$transaction([
|
|
this.prisma.foodTypes.findMany({
|
|
where: { isActive: true },
|
|
orderBy: { foodTypeName: 'asc' },
|
|
}),
|
|
this.prisma.foodCuisines.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.transportModes.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.navigationModes.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.taxes.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.energyLevels.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.amenities.findMany({
|
|
where: { isActive: true },
|
|
}),
|
|
this.prisma.allowedEntryTypes.findMany({
|
|
where: { isActive: true },
|
|
orderBy: { id: 'asc' }
|
|
}),
|
|
this.prisma.ageRestrictions.findMany({
|
|
where: { isActive: true },
|
|
orderBy: { ageRestrictionName: 'asc' }
|
|
}),
|
|
]);
|
|
|
|
return {
|
|
foodType,
|
|
cuisineDetails,
|
|
vehicleType,
|
|
navigationMode,
|
|
taxDetails,
|
|
energyLevel,
|
|
aminitiesDetails,
|
|
allowedEntryType,
|
|
ageRestrictionDetails
|
|
};
|
|
}
|
|
}
|