Class NotificationService
java.lang.Object
edu.ntnu.idatt2106_2023_06.backend.service.notification.NotificationService
- All Implemented Interfaces:
INotificationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteAllNotificationsForOneUser(Long fridgeId) Deletes all notifications for a user in a fridge.voiddeleteNotification(Long notificationId) Deletes a notification.voiddeleteNotificationForEveryUserInFridge(ItemRemoveDTO itemRemoveDTO) Deletes a notification for every user in a fridge.Get all notifications of a user.Get all notifications of a user as DTOs.voidSets all notifications for a user as read.voidsetNotificationAsRead(UpdateNotificationDTO updateNotificationDTO) Sets a notification as read.voidUpdates all notifications of a user.voidupdateNotifications(Long fridgeId) Updates all notifications for a user in a fridge.
-
Constructor Details
-
NotificationService
public NotificationService()
-
-
Method Details
-
updateAllNotifications
public void updateAllNotifications()Updates all notifications of a user. -
updateNotifications
Updates all notifications for a user in a fridge. This is done by checking if any items in the fridge are about to expire, and if so, creating a notification for the user.- Parameters:
fridgeId- The id of the fridge to update notifications for.
-
getAllNotificationsOfSingeUser
Get all notifications of a user. Uses the JWT token to get the user. -
getAllNotificationsOfSingeUserAsDTO
Get all notifications of a user as DTOs. Uses the JWT token to get the user.- Returns:
- A list of notifications as DTOs.
-
setNotificationAsRead
Sets a notification as read.- Parameters:
updateNotificationDTO- The notification to set as read.
-
setAllNotificationsAsRead
public void setAllNotificationsAsRead()Sets all notifications for a user as read. -
deleteNotificationForEveryUserInFridge
Deletes a notification for every user in a fridge. This method should be called when removing an item from a fridge.- Parameters:
itemRemoveDTO- The item to delete.
-
deleteAllNotificationsForOneUser
Deletes all notifications for a user in a fridge.- Parameters:
fridgeId- The id of the fridge to delete notifications for.
-
deleteNotification
Deletes a notification. for a user.- Parameters:
notificationId- The id of the notification to delete.
-