fixed more previous merge mistakes...
This commit is contained in:
parent
800c9d96cd
commit
2c1f40bc5f
@ -775,6 +775,20 @@ public class Controller {
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(teamStatus));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getTeam")
|
||||
public ResponseEntity getTeam(@RequestParam String name){
|
||||
ResponseEntity responseEntity = FinderUtil.findTeamByName(name);
|
||||
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getTeamMembers")
|
||||
public ResponseEntity getTeamMembers(@RequestParam String name){
|
||||
return FinderUtil.findTeammemberByTeamName(name);
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
||||
@RequestMapping("/api/getCurrentStation")
|
||||
@ResponseBody
|
||||
|
||||
@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -159,4 +160,33 @@ public class FinderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static ResponseEntity findTeamByName(String name) {
|
||||
|
||||
Team team = teamRepository.findByName(name);
|
||||
if (team != null) {
|
||||
return ResponseEntity.status(200).body(team);
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("Couldnt find Team with name " + name);
|
||||
}
|
||||
}
|
||||
|
||||
public static ResponseEntity findTeammemberByTeamName(String name) {
|
||||
|
||||
List<Object[]> list = teamRepository.getTeammembers(name);
|
||||
if (list != null) {
|
||||
|
||||
List<User> sendBack = new LinkedList<>();
|
||||
|
||||
for (Object[] obj :
|
||||
list) {
|
||||
User tmp = new User();
|
||||
tmp.setUsername((String) obj[3]);
|
||||
sendBack.add(tmp);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(200).body(sendBack);
|
||||
} else {
|
||||
return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user