added teamStatus and setTeamStatus API method
This commit is contained in:
parent
ac484e5d0c
commit
d9a76e9783
@ -757,6 +757,58 @@ public class Controller {
|
||||
return ResponseEntity.status(200).body("OK");
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/setTeamStatus")
|
||||
@ResponseBody
|
||||
public ResponseEntity setTeamStatus(@RequestParam String token,
|
||||
@RequestParam String teamStatus) {
|
||||
// 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();
|
||||
|
||||
//Get User_Info
|
||||
ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
|
||||
|
||||
if (getUser_Info.getStatusCodeValue() != 200) {
|
||||
return getUser_Info;
|
||||
}
|
||||
|
||||
User_Info user_info = (User_Info) getUser_Info.getBody();
|
||||
//----------------------
|
||||
if (user_info.getTeam() == null) {
|
||||
return ResponseEntity.status(400).body("You aren´t in any team");
|
||||
}
|
||||
|
||||
//Get team
|
||||
ResponseEntity getTeam = FinderUtil.findTeamById(String.valueOf(user_info.getTeam().getId()));
|
||||
|
||||
if (getTeam.getStatusCodeValue() != 200) {
|
||||
return getTeam;
|
||||
}
|
||||
|
||||
Team team = (Team) getTeam.getBody();
|
||||
team.setTeamStatus(teamStatus);
|
||||
|
||||
teamRepository.save(team);
|
||||
|
||||
return ResponseEntity.status(200).body(teamStatus);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/api/hello")
|
||||
public ResponseEntity hello(@RequestParam String name) {
|
||||
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
|
||||
|
||||
@ -14,6 +14,8 @@ public class Team {
|
||||
|
||||
private String name;
|
||||
|
||||
private String teamStatus;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@ -29,4 +31,12 @@ public class Team {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTeamStatus() {
|
||||
return teamStatus;
|
||||
}
|
||||
|
||||
public void setTeamStatus(String teamStatus) {
|
||||
this.teamStatus = teamStatus;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user