add: notif error log

This commit is contained in:
2025-11-25 11:59:44 +07:00
parent 44107c9753
commit 78a813e9ec
6 changed files with 193 additions and 25 deletions

View File

@@ -0,0 +1,80 @@
const {
getAllNotificationErrorLogDb,
getNotificationErrorLogByIdDb,
getNotificationErrorLogByNotificationErrorIdDb,
createNotificationErrorLogDb,
updateNotificationErrorLogDb,
deleteNotificationErrorLogDb
} = require('../db/notification_error_log.db');
const { ErrorHandler } = require('../helpers/error');
class NotificationErrorLogService {
// Get all Notification Error Logs
static async getAllNotificationErrorLog() {
try {
const results = await getAllNotificationErrorLogDb();
results.data.map(element => {
});
return results;
} catch (error) {
throw new ErrorHandler(error.statusCode, error.message);
}
}
// Get Notification Error Log by ID
static async getNotificationErrorLogById(id) {
try {
const result = await getNotificationErrorLogByIdDb(id);
if (!result) {
throw new ErrorHandler(404, 'Notification Error Log not found');
}
return result;
} catch (error) {
throw new ErrorHandler(error.statusCode, error.message);
}
}
// Create Notification Error Log
static async createNotificationErrorLog(data) {
try {
if (!data || typeof data !== 'object') data = {};
const store = {
notification_error_id: data.notification_error_id,
contact_id: data.contact_id,
notification_error_log_description: data.notification_error_log_description,
created_by: data.created_by
};
const result = await createNotificationErrorLogDb(store);
return result;
} catch (error) {
throw new ErrorHandler(error.statusCode, error.message);
}
}
// Soft delete Notification Error Log
static async deleteNotificationErrorLog(id, userId) {
try {
const dataExist = await getNotificationErrorLogByIdDb(id);
if (!dataExist) {
throw new ErrorHandler(404, 'Notification Error Log not found');
}
const result = await deleteNotificationErrorLogDb(id, userId);
return result;
} catch (error) {
throw new ErrorHandler(error.statusCode, error.message);
}
}
}
module.exports = NotificationErrorLogService;