added getMyTeamInvites API method
This commit is contained in:
parent
31d7bf3c51
commit
06e2b54aef
@ -694,6 +694,39 @@ public class Controller {
|
|||||||
return ResponseEntity.status(200).body("OK");
|
return ResponseEntity.status(200).body("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
|
@RequestMapping("/api/getMyTeamInvites")
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseEntity getMyTeamInvites(@RequestParam String token) {
|
||||||
|
// verify user
|
||||||
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||||
|
|
||||||
|
if (verifyToken.getStatusCodeValue() != 200) {
|
||||||
|
return verifyToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
//get User
|
||||||
|
Claims claims = (Claims) verifyToken.getBody();
|
||||||
|
|
||||||
|
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
||||||
|
|
||||||
|
if (getUser.getStatusCodeValue() != 200) {
|
||||||
|
return getUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
User user = (User) getUser.getBody();
|
||||||
|
|
||||||
|
List<TeamInvite> teamInvitesList = new ArrayList<>();
|
||||||
|
|
||||||
|
for(TeamInvite teamInvite : teamInviteRepository.findAll()) {
|
||||||
|
if(teamInvite.getUser() == user) {
|
||||||
|
teamInvitesList.add(teamInvite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(200).body(teamInvitesList);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/api/hello")
|
@RequestMapping("/api/hello")
|
||||||
public ResponseEntity hello(@RequestParam String name) {
|
public ResponseEntity hello(@RequestParam String name) {
|
||||||
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
|
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user