Class UserController


  • @RestController
    @RequestMapping("/users")
    @ExposesResourceFor(User.class)
    public class UserController
    extends java.lang.Object
    UserController provides endpoints which allow the client to access data relating to User.
    Since:
    1.0
    Version:
    1.0
    Author:
    Robert Dominugez, Roderick Frechette, Laura Steiner
    • Constructor Summary

      Constructors 
      Constructor Description
      UserController​(UserService userService)
      Autowired constructor for UserController.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete​(org.springframework.security.core.Authentication auth)
      Deletes the current user.
      User get​(long userId, org.springframework.security.core.Authentication auth)
      Gets a selected user.
      java.util.List<User> getAll​(org.springframework.security.core.Authentication auth, int limit, int offset)
      Gets all users, limited by parameters.
      User me​(org.springframework.security.core.Authentication auth)
      Gets the current user.
      User.Genre updateGenre​(org.springframework.security.core.Authentication auth, User.Genre genre)
      Updates the current user's favorite genre.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UserController

        @Autowired
        public UserController​(UserService userService)
        Autowired constructor for UserController.
        Parameters:
        userService - UserService
    • Method Detail

      • me

        @GetMapping(value="/me",
                    produces="application/json")
        public User me​(org.springframework.security.core.Authentication auth)
        Gets the current user.
        Parameters:
        auth - Authentication
        Returns:
        the current user
      • get

        @GetMapping(value="/{userId}",
                    produces="application/json")
        public User get​(@PathVariable
                        long userId,
                        org.springframework.security.core.Authentication auth)
        Gets a selected user.
        Parameters:
        userId - long
        auth - Authentication
        Returns:
        User
      • getAll

        @GetMapping(produces="application/json")
        public java.util.List<User> getAll​(org.springframework.security.core.Authentication auth,
                                           @RequestParam(required=false,defaultValue="40")
                                           int limit,
                                           @RequestParam(required=false,defaultValue="0")
                                           int offset)
        Gets all users, limited by parameters.
        Parameters:
        auth - Authentication
        limit - int
        offset - int
        Returns:
        List<User>
      • updateGenre

        @PutMapping(value="/me/genre",
                    consumes="text/plain",
                    produces="text/plain")
        public User.Genre updateGenre​(org.springframework.security.core.Authentication auth,
                                      @RequestBody
                                      User.Genre genre)
        Updates the current user's favorite genre.
        Parameters:
        auth - Authentication
        genre - Genre enum
        Returns:
        Genre enum
      • delete

        @ResponseStatus(NO_CONTENT)
        @DeleteMapping(value="/me",
                       consumes="application/json")
        public void delete​(org.springframework.security.core.Authentication auth)
        Deletes the current user.
        Parameters:
        auth - Authentication