repair: crud notification error sparepart

This commit is contained in:
2025-11-18 13:50:23 +07:00
parent 46c69aafa0
commit 5e4a992834
2 changed files with 12 additions and 3 deletions

View File

@@ -5,8 +5,9 @@ const { updateNotificationErrorSparepartSchema, insertNotificationErrorSparepart
class NotificationErrorSparepartController {
static async getAll(req, res) {
const { contact_id } = req.body;
const queryParams = req.query;
const results = await NotificationErrorSparepart.getAll(queryParams);
const results = await NotificationErrorSparepart.getAll(queryParams, contact_id);
const response = await setResponsePaging(queryParams, results, 'Notification Error Sparepart found');
res.status(response.statusCode).json(response);

View File

@@ -14,12 +14,20 @@ class NotificationErrorSparepartService {
if (contactType !== "gudang") {
throw new ErrorHandler(
403,
"Akses ditolak. Hanya contact_type 'gudang' yang dapat create/update/delete."
"Akses ditolak. Hanya contact_type 'gudang' yang dapat getAll/create/update/delete."
);
}
}
static async getAll(param) {
static async getAll(param, contact_id) {
const contactResult = await getContactByIdDb(contact_id);
if (!contactResult || contactResult.length < 1)
throw new ErrorHandler(404, "Contact tidak ditemukan");
const contact = contactResult[0];
this._checkAccess(contact.contact_type);
return await getAllNotificationErrorSparepartDb(param);
}