Class UserController
- java.lang.Object
-
- edu.cnm.deepdive.tunefull.controller.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 toUser
.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Robert Dominugez, Roderick Frechette, Laura Steiner
-
-
Constructor Summary
Constructors Constructor Description UserController(UserService userService)
Autowired constructor forUserController
.
-
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.
-
-
-
Constructor Detail
-
UserController
@Autowired public UserController(UserService userService)
Autowired constructor forUserController
.- 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
- longauth
- 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
- Authenticationlimit
- intoffset
- 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
- Authenticationgenre
- 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
-
-