const { getAllNotificationErrorUserDb, getNotificationErrorUserByIdDb, createNotificationErrorUserDb, updateNotificationErrorUserDb, deleteNotificationErrorUserDb } = require('../db/notification_error_user.db'); const { ErrorHandler } = require('../helpers/error'); class NotificationErrorUserService { // Get all Contact static async getAllNotificationErrorUser(param) { try { const results = await getAllNotificationErrorUserDb(param); results.data.map(element => { }); return results } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Get NotificationErrorUser by ID static async getNotificationErrorUserById(id) { try { const result = await getNotificationErrorUserByIdDb(id); if (result.length < 1) throw new ErrorHandler(404, 'NotificationErrorUser not found'); return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Create NotificationErrorUser static async createNotificationErrorUser(data) { try { if (!data || typeof data !== 'object') data = {}; const result = await createNotificationErrorUserDb(data); return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Update NotificationErrorUser static async updateNotificationErrorUser(id, data) { try { if (!data || typeof data !== 'object') data = {}; const dataExist = await getNotificationErrorUserByIdDb(id); if (dataExist.length < 1) { throw new ErrorHandler(404, 'NotificationErrorUser not found'); } const result = await updateNotificationErrorUserDb(id, data); return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } // Soft delete NotificationErrorUser static async deleteNotificationErrorUser(id, userId) { try { const dataExist = await getNotificationErrorUserByIdDb(id); if (dataExist.length < 1) { throw new ErrorHandler(404, 'NotificationErrorUser not found'); } const result = await deleteNotificationErrorUserDb(id, userId); return result; } catch (error) { throw new ErrorHandler(error.statusCode, error.message); } } } module.exports = NotificationErrorUserService;