Class NotificationService

java.lang.Object
edu.ntnu.idatt2106_2023_06.backend.service.notification.NotificationService
All Implemented Interfaces:
INotificationService

@Service public class NotificationService extends Object implements INotificationService
  • Constructor Details

    • NotificationService

      public NotificationService()
  • Method Details

    • updateAllNotifications

      public void updateAllNotifications()
      Updates all notifications of a user.
    • updateNotifications

      public void updateNotifications(Long fridgeId)
      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

      public List<Notification> getAllNotificationsOfSingeUser()
      Get all notifications of a user. Uses the JWT token to get the user.
    • getAllNotificationsOfSingeUserAsDTO

      public List<NotificationDTO> 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

      public void setNotificationAsRead(UpdateNotificationDTO updateNotificationDTO)
      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

      public void deleteNotificationForEveryUserInFridge(ItemRemoveDTO itemRemoveDTO)
      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

      public void deleteAllNotificationsForOneUser(Long fridgeId)
      Deletes all notifications for a user in a fridge.
      Parameters:
      fridgeId - The id of the fridge to delete notifications for.
    • deleteNotification

      public void deleteNotification(Long notificationId)
      Deletes a notification. for a user.
      Parameters:
      notificationId - The id of the notification to delete.