repair: notification error log
This commit is contained in:
@@ -31,6 +31,21 @@ class NotificationErrorLogController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get notification error logs by notification_error_id
|
||||||
|
static async getByNotificationErrorId(req, res) {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
const results = await NotificationErrorLogService.getNotificationErrorLogByNotificationErrorId(id);
|
||||||
|
const response = await setResponse(results, 'Notification Error Logs found')
|
||||||
|
|
||||||
|
res.status(response.statusCode).json(response);
|
||||||
|
} catch (error) {
|
||||||
|
const response = await setResponse(error, error.message, error.statusCode || 500);
|
||||||
|
res.status(response.statusCode).json(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create notification error log
|
// Create notification error log
|
||||||
static async create(req, res) {
|
static async create(req, res) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -12,4 +12,7 @@ router.route("/")
|
|||||||
router.route("/:id")
|
router.route("/:id")
|
||||||
.get(verifyToken.verifyAccessToken, NotificationErrorLogController.getById);
|
.get(verifyToken.verifyAccessToken, NotificationErrorLogController.getById);
|
||||||
|
|
||||||
|
router.route("/notification_error/:id")
|
||||||
|
.get(verifyToken.verifyAccessToken, NotificationErrorLogController.getByNotificationErrorId);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
@@ -14,6 +14,7 @@ const {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
getAllNotificationErrorLogDb,
|
getAllNotificationErrorLogDb,
|
||||||
|
getNotificationErrorLogByNotificationErrorIdDb,
|
||||||
} = require('../db/notification_error_log.db');
|
} = require('../db/notification_error_log.db');
|
||||||
|
|
||||||
const { getFileUploadByPathDb } = require('../db/file_uploads.db');
|
const { getFileUploadByPathDb } = require('../db/file_uploads.db');
|
||||||
@@ -78,8 +79,7 @@ class NotificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get activity logs for this notification
|
// Get activity logs for this notification
|
||||||
const activityLogs = (await getAllNotificationErrorLogDb()) || [];
|
const notificationLogs = (await getNotificationErrorLogByNotificationErrorIdDb(id)) || [];
|
||||||
const notificationLogs = activityLogs.filter(log => log.notification_error_id === parseInt(id));
|
|
||||||
|
|
||||||
notification.activity_logs = notificationLogs;
|
notification.activity_logs = notificationLogs;
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,17 @@ class NotificationErrorLogService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Notification Error Log by notification_error_id
|
||||||
|
static async getNotificationErrorLogByNotificationErrorId(notificationErrorId) {
|
||||||
|
try {
|
||||||
|
const results = await getNotificationErrorLogByNotificationErrorIdDb(notificationErrorId);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
} catch (error) {
|
||||||
|
throw new ErrorHandler(error.statusCode, error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Soft delete Notification Error Log
|
// Soft delete Notification Error Log
|
||||||
static async deleteNotificationErrorLog(id, userId) {
|
static async deleteNotificationErrorLog(id, userId) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user