Class EventService


  • @Service
    public class EventService
    extends Object
    This is a @Service class and holds the additional logic for the queries involving an Event in the PicMe database.
    • Constructor Detail

      • EventService

        @Autowired
        public EventService​(EventRepository eventRepository)
        This initializes and creates an EventService object with the eventRepository.
        Parameters:
        eventRepository - this is the repository field passed in that allows us to run JPA queries.
    • Method Detail

      • save

        public Event save​(Event event,
                          User user,
                          String passkey,
                          String name)
        This is a method to save an Event object
        Parameters:
        event - is the new event being created
        user - is the user creating an event
        passkey - is the event password that the user sets for the new event
        name - is the name of the new event being created
        Returns:
        an Event that is saved.
      • get

        public Optional<Event> get​(long id,
                                   String passkey)
        Gets a specified event by the event id and passkey
        Parameters:
        id - this is the event primary key.
        passkey - the user created passkey for an event
        Returns:
        this returns an Event if the id and passkey match up.
      • get

        public Optional<Event> get​(long id,
                                   User user)
        This method returns an event by passing in the User who created it and the associated event id.
        Parameters:
        id - this is the event primary key.
        user - this is the current signed in User of the application
        Returns:
        an Event object, if there are any associated with the User.
      • getAllUserEvents

        public List<Event> getAllUserEvents​(User user)
        This gets all the Events created by a user.
        Parameters:
        user - is a User object, specifically the one who created the event.
        Returns:
        a list of Event objects, if there are any associated with the User.
      • delete

        public void delete​(Event event)
        A method that deletes a specified event
        Parameters:
        event - the Event object to be deleted