added a getTeamRankingList API method

This commit is contained in:
Michael 2019-04-27 20:17:24 +02:00
parent 50f7204cf5
commit 1a6fb9d35e

View File

@ -3,6 +3,7 @@ package hhn.labsw.bugageocaching.controller;
import com.google.gson.Gson;
import hhn.labsw.bugageocaching.entities.*;
import hhn.labsw.bugageocaching.helper.RankingListHelper;
import hhn.labsw.bugageocaching.helper.TeamRankingListHelper;
import hhn.labsw.bugageocaching.repositories.*;
import hhn.labsw.bugageocaching.util.FinderUtil;
import hhn.labsw.bugageocaching.util.VerificationUtil;
@ -396,6 +397,21 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getTeamRankingList")
@ResponseBody
public ResponseEntity getTeamRankingList() {
List<TeamRankingListHelper> sendBackTeams = new LinkedList<>();
List<Object[]> rankingTeams = userRepository.getTeamRankingList();
for (Object[] obj : rankingTeams) {
TeamRankingListHelper tmp = new TeamRankingListHelper((String) obj[0], (Integer) obj[1]);
System.out.println(tmp);
sendBackTeams.add(tmp);
}
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping("/api/getUser")
@ResponseBody