Class UserService


  • @Service
    public class UserService
    extends java.lang.Object
    • Constructor Detail

      • UserService

        public UserService()
    • Method Detail

      • getUser

        public UserDTO getUser​(long userId)
        Finds user in Database, and creates a DTO object from it
        Parameters:
        userId -
        Returns:
        DTO object from User
      • editUser

        public UserDTO editUser​(long userId,
                                UserEditDTO userDTO)
        Edits a stored User object with userDTO fields
        Parameters:
        userId -
        userDTO - input object
        Returns:
        UserDTO object
      • deleteUser

        public boolean deleteUser​(long userId)
        Deletes a user from the database, and checks if it exists after
        Parameters:
        userId -
        Returns:
        if it exists or not
      • getUserActivities

        public java.util.Set<Activity> getUserActivities​(long userId)
        Gets all activities where the user has signed up
        Parameters:
        userId -
        Returns:
        List of activities
      • removeUserFromActivity

        public boolean removeUserFromActivity​(long userId,
                                              long activityId)
        Removes a user from an activity. Returns true if successful, else false
        Parameters:
        userId -
        activityId -
        Returns:
      • addUserToActivity

        public Activity addUserToActivity​(long userId,
                                          long activityId)
        Adds a user to an activity. Returns true if successful, else false
        Parameters:
        userId -
        activityId -
        Returns:
      • doesEmailAlreadyExist

        public boolean doesEmailAlreadyExist​(java.lang.String email)
        Checks if the email already exists in the database
        Parameters:
        email -
        Returns:
      • isOldPasswordCorrect

        public boolean isOldPasswordCorrect​(java.lang.String oldPassword,
                                            long userId)
        Finds user from id and and compares user's hashed password with input password(oldPassword)
        Parameters:
        oldPassword -
        userId -
        Returns:
        if passwords are equal
      • findFutureActivities

        public java.util.List<Activity> findFutureActivities​(long userId)
        Finds future activities that the user has signed up to
        Parameters:
        userId -
        Returns:
        List of activities
      • findOrganizedActivities

        public java.util.List<Activity> findOrganizedActivities​(long userId)
        Finds all acitivites that a user is an organizer of
        Parameters:
        userId -
        Returns:
        List of activities