repair: crud notification error sparepart
This commit is contained in:
@@ -5,8 +5,9 @@ const { updateNotificationErrorSparepartSchema, insertNotificationErrorSparepart
|
|||||||
class NotificationErrorSparepartController {
|
class NotificationErrorSparepartController {
|
||||||
|
|
||||||
static async getAll(req, res) {
|
static async getAll(req, res) {
|
||||||
|
const { contact_id } = req.body;
|
||||||
const queryParams = req.query;
|
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');
|
const response = await setResponsePaging(queryParams, results, 'Notification Error Sparepart found');
|
||||||
|
|
||||||
res.status(response.statusCode).json(response);
|
res.status(response.statusCode).json(response);
|
||||||
|
|||||||
@@ -14,12 +14,20 @@ class NotificationErrorSparepartService {
|
|||||||
if (contactType !== "gudang") {
|
if (contactType !== "gudang") {
|
||||||
throw new ErrorHandler(
|
throw new ErrorHandler(
|
||||||
403,
|
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);
|
return await getAllNotificationErrorSparepartDb(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user