feat(support): update Swagger documentation for support endpoints
This commit is contained in:
@@ -13,6 +13,8 @@ const getAllSupportFromDB = async (
|
||||
search?: string,
|
||||
type?: string,
|
||||
status?: string,
|
||||
page: number = 1,
|
||||
limit: number = 10,
|
||||
) => {
|
||||
const andCondition: Prisma.SupportWhereInput[] = [];
|
||||
|
||||
@@ -55,14 +57,31 @@ const getAllSupportFromDB = async (
|
||||
const whereCondition: Prisma.SupportWhereInput =
|
||||
andCondition.length > 0 ? { AND: andCondition } : {};
|
||||
|
||||
const result = await prisma.support.findMany({
|
||||
where: whereCondition,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
});
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
return result;
|
||||
const [data, total] = await Promise.all([
|
||||
prisma.support.findMany({
|
||||
where: whereCondition,
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
}),
|
||||
prisma.support.count({
|
||||
where: whereCondition,
|
||||
}),
|
||||
]);
|
||||
|
||||
return {
|
||||
meta: {
|
||||
page,
|
||||
limit,
|
||||
total,
|
||||
totalPage: Math.ceil(total / limit),
|
||||
},
|
||||
data,
|
||||
};
|
||||
};
|
||||
|
||||
const getSingleSupportFromDB = async (
|
||||
@@ -125,8 +144,8 @@ const deleteSupportFromDB = async (
|
||||
}
|
||||
|
||||
const result = await prisma.support.delete({
|
||||
where: {id}
|
||||
})
|
||||
where: { id },
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user