Class RelationshipController
- java.lang.Object
-
- edu.cnm.deepdive.tunefull.controller.RelationshipController
-
@RestController @ExposesResourceFor(Relationship.class) public class RelationshipController extends java.lang.Object
RelationshipController
provides endpoints which allow the client to access data relating toRelationship
.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Robert Dominugez, Roderick Frechette, Laura Steiner
-
-
Constructor Summary
Constructors Constructor Description RelationshipController(RelationshipService relationshipService, UserService userService)
Autowired constructor forRelationshipController
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Relationship>
myFollows(org.springframework.security.core.Authentication auth)
Gets all relationships in which the current user is following another user.java.util.List<Relationship>
myFriends(org.springframework.security.core.Authentication auth)
Gets all relationships in which the current user is a friend.java.util.List<Relationship>
myPendingRequests(org.springframework.security.core.Authentication auth)
Gets all relationships in which the user has received a friend request and hasn't yet responded.Relationship
requestFriendship(org.springframework.security.core.Authentication auth, User user)
Creates a relationship between the current user and another user.boolean
setFriendshipAccepted(org.springframework.security.core.Authentication auth, long relationshipId, boolean accepted)
Updates a relationship between two users.Relationship
startFollowing(org.springframework.security.core.Authentication auth, User user)
Lets the current user start following another user.
-
-
-
Constructor Detail
-
RelationshipController
public RelationshipController(RelationshipService relationshipService, UserService userService)
Autowired constructor forRelationshipController
.- Parameters:
relationshipService
- RelationshipServiceuserService
- UserService
-
-
Method Detail
-
myFriends
@GetMapping(value="/friendships", produces="application/json") public java.util.List<Relationship> myFriends(org.springframework.security.core.Authentication auth)
Gets all relationships in which the current user is a friend.- Parameters:
auth
- Authentication- Returns:
- List<Relationship>
-
myFollows
@GetMapping(value="/follows", produces="application/json") public java.util.List<Relationship> myFollows(org.springframework.security.core.Authentication auth)
Gets all relationships in which the current user is following another user.- Parameters:
auth
- Authentication- Returns:
- List<Relationship>
-
myPendingRequests
@GetMapping(value="/pending", produces="application/json") public java.util.List<Relationship> myPendingRequests(org.springframework.security.core.Authentication auth)
Gets all relationships in which the user has received a friend request and hasn't yet responded.- Parameters:
auth
- Authentication- Returns:
- List<Relationship>
-
requestFriendship
@ResponseStatus(CREATED) @PostMapping(value="/friendships", consumes="application/json", produces="application/json") public Relationship requestFriendship(org.springframework.security.core.Authentication auth, @RequestBody User user)
Creates a relationship between the current user and another user. This relationship is not yet a friendship, but is a follow and a friend request rolled into one.- Parameters:
auth
- Authenticationuser
- User- Returns:
- a new relationship between two users.
-
startFollowing
@ResponseStatus(CREATED) @PostMapping(value="/follows", consumes="application/json", produces="application/json") public Relationship startFollowing(org.springframework.security.core.Authentication auth, @RequestBody User user)
Lets the current user start following another user.- Parameters:
auth
- Authenticationuser
- User- Returns:
- a new relationship following another user
-
setFriendshipAccepted
@PutMapping(value="/friendships/{relationshipId}", consumes="application/json", produces="application/json") public boolean setFriendshipAccepted(org.springframework.security.core.Authentication auth, @PathVariable long relationshipId, @RequestBody boolean accepted)
Updates a relationship between two users.- Parameters:
auth
- AuthenticationrelationshipId
- longaccepted
- boolean- Returns:
- the updated relationship
-
-