archetecture security fix
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findMany = findMany;
|
||||
exports.findById = findById;
|
||||
exports.create = create;
|
||||
exports.updateById = updateById;
|
||||
exports.deleteById = deleteById;
|
||||
const prisma_1 = require("../../lib/prisma");
|
||||
const COMPLAINT_INCLUDE = {
|
||||
reservation: {
|
||||
select: {
|
||||
id: true,
|
||||
startDate: true,
|
||||
endDate: true,
|
||||
status: true,
|
||||
vehicle: { select: { make: true, model: true, year: true } },
|
||||
},
|
||||
},
|
||||
customer: {
|
||||
select: {
|
||||
id: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
email: true,
|
||||
phone: true,
|
||||
},
|
||||
},
|
||||
review: {
|
||||
select: {
|
||||
id: true,
|
||||
overallRating: true,
|
||||
comment: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
async function findMany(companyId, where, skip, take) {
|
||||
const baseWhere = { companyId, ...where };
|
||||
return Promise.all([
|
||||
prisma_1.prisma.complaint.findMany({
|
||||
where: baseWhere,
|
||||
include: COMPLAINT_INCLUDE,
|
||||
skip,
|
||||
take,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma_1.prisma.complaint.count({ where: baseWhere }),
|
||||
]);
|
||||
}
|
||||
async function findById(id, companyId) {
|
||||
return prisma_1.prisma.complaint.findFirst({
|
||||
where: { id, companyId },
|
||||
include: COMPLAINT_INCLUDE,
|
||||
});
|
||||
}
|
||||
async function create(data) {
|
||||
return prisma_1.prisma.complaint.create({
|
||||
data: data,
|
||||
include: COMPLAINT_INCLUDE,
|
||||
});
|
||||
}
|
||||
async function updateById(id, data) {
|
||||
return prisma_1.prisma.complaint.update({
|
||||
where: { id },
|
||||
data,
|
||||
include: COMPLAINT_INCLUDE,
|
||||
});
|
||||
}
|
||||
async function deleteById(id) {
|
||||
return prisma_1.prisma.complaint.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=complaint.repo.js.map
|
||||
Reference in New Issue
Block a user