implemented getStationPOIS
This commit is contained in:
parent
c86ce22d27
commit
6ca87f84fc
@ -2,6 +2,7 @@ package hhn.labsw.bugageocaching.controller;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import hhn.labsw.bugageocaching.entities.*;
|
import hhn.labsw.bugageocaching.entities.*;
|
||||||
|
import hhn.labsw.bugageocaching.helper.POI;
|
||||||
import hhn.labsw.bugageocaching.helper.RankingListHelper;
|
import hhn.labsw.bugageocaching.helper.RankingListHelper;
|
||||||
import hhn.labsw.bugageocaching.helper.TeamRankingListHelper;
|
import hhn.labsw.bugageocaching.helper.TeamRankingListHelper;
|
||||||
import hhn.labsw.bugageocaching.repositories.*;
|
import hhn.labsw.bugageocaching.repositories.*;
|
||||||
@ -724,7 +725,7 @@ public class Controller {
|
|||||||
|
|
||||||
|
|
||||||
//Get User_Info
|
//Get User_Info
|
||||||
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
|
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
|
||||||
//----------------------
|
//----------------------
|
||||||
if (user_info.getTeam() == null) {
|
if (user_info.getTeam() == null) {
|
||||||
return ResponseEntity.status(400).body("You aren´t in any team");
|
return ResponseEntity.status(400).body("You aren´t in any team");
|
||||||
@ -853,7 +854,7 @@ public class Controller {
|
|||||||
User user = (User) getUser.getBody();
|
User user = (User) getUser.getBody();
|
||||||
|
|
||||||
//Get User_Info
|
//Get User_Info
|
||||||
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
|
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
|
||||||
//----------------------
|
//----------------------
|
||||||
if (user_info.getTeam() == null) {
|
if (user_info.getTeam() == null) {
|
||||||
return ResponseEntity.status(400).body("You aren´t in any team");
|
return ResponseEntity.status(400).body("You aren´t in any team");
|
||||||
@ -880,7 +881,7 @@ public class Controller {
|
|||||||
})
|
})
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping(value = "/api/getTeam", method = RequestMethod.GET, produces = "application/json")
|
@RequestMapping(value = "/api/getTeam", method = RequestMethod.GET, produces = "application/json")
|
||||||
public ResponseEntity getTeam(@RequestParam String name){
|
public ResponseEntity getTeam(@RequestParam String name) {
|
||||||
ResponseEntity responseEntity = FinderUtil.findTeamByName(name);
|
ResponseEntity responseEntity = FinderUtil.findTeamByName(name);
|
||||||
|
|
||||||
return responseEntity;
|
return responseEntity;
|
||||||
@ -892,7 +893,7 @@ public class Controller {
|
|||||||
})
|
})
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping(value = "/api/getTeamMembers", method = RequestMethod.GET, produces = "application/json")
|
@RequestMapping(value = "/api/getTeamMembers", method = RequestMethod.GET, produces = "application/json")
|
||||||
public ResponseEntity getTeamMembers(@RequestParam String name){
|
public ResponseEntity getTeamMembers(@RequestParam String name) {
|
||||||
return FinderUtil.findTeammemberByTeamName(name);
|
return FinderUtil.findTeammemberByTeamName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -906,7 +907,7 @@ public class Controller {
|
|||||||
@RequestMapping(value = "/api/getCurrentStation", method = RequestMethod.GET, produces = "application/json")
|
@RequestMapping(value = "/api/getCurrentStation", method = RequestMethod.GET, produces = "application/json")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity getStationFromUserAndCache(@RequestParam String token,
|
public ResponseEntity getStationFromUserAndCache(@RequestParam String token,
|
||||||
@RequestParam String cacheID){
|
@RequestParam String cacheID) {
|
||||||
|
|
||||||
// verify user
|
// verify user
|
||||||
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||||
@ -948,7 +949,7 @@ public class Controller {
|
|||||||
})
|
})
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json")
|
@RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json")
|
||||||
public ResponseEntity getRankingPlace(@RequestParam String token){
|
public ResponseEntity getRankingPlace(@RequestParam String token) {
|
||||||
|
|
||||||
// verify user
|
// verify user
|
||||||
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||||
@ -971,10 +972,66 @@ public class Controller {
|
|||||||
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(user.getUsername()));
|
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(user.getUsername()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "Returns startstations and all other stations he user already visited as POIS")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 404, message = "Database error"),
|
||||||
|
@ApiResponse(code = 401, message = "JWT Token expired"),
|
||||||
|
@ApiResponse(code = 400, message = "Something went wrong at verification")
|
||||||
|
})
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
// @RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json")
|
@RequestMapping(value = "/api/getStationPOIS", method = RequestMethod.GET, produces = "application/json")
|
||||||
public ResponseEntity getMyMap() {
|
public ResponseEntity getStationPOIS(@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();
|
||||||
|
//
|
||||||
|
|
||||||
|
ArrayList<POI> poisList = new ArrayList<>();
|
||||||
|
for (Cache cache : cacheRepository.findAll()) {
|
||||||
|
Station station = cache.getStationen().get(0);
|
||||||
|
POI poi = new POI(cache.getName() + "_Station1", (float) station.getLattitude(), (float) station.getLongitude(), 0);
|
||||||
|
poisList.add(poi);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Bearbeitet bearbeitet : bearbeitetRepository.findAll()) {
|
||||||
|
if (bearbeitet.getUser() == user) {
|
||||||
|
Cache cache = bearbeitet.getCache();
|
||||||
|
Station aktuelleStation = bearbeitet.getAktuelleStation();
|
||||||
|
int index = cache.getStationen().indexOf(aktuelleStation);
|
||||||
|
for (int i = 1; i <= index; i++) {
|
||||||
|
Station station = cache.getStationen().get(i);
|
||||||
|
int categoryID;
|
||||||
|
if (i < cache.getStationen().size() - 1) { // isnt endstation
|
||||||
|
categoryID = 1;
|
||||||
|
} else { // is endstation
|
||||||
|
categoryID = 2;
|
||||||
|
}
|
||||||
|
POI poi = new POI(cache.getName() + "_Station" + (i + 1), (float) station.getLattitude(), (float) station.getLongitude(), categoryID);
|
||||||
|
poisList.add(poi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
POI[] pois = new POI[poisList.size()];
|
||||||
|
for (int i = 0; i < poisList.size(); i++) {
|
||||||
|
pois[i] = poisList.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(200).body(new Gson().toJson(pois));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "Test method (Changes its purpose often)")
|
@ApiOperation(value = "Test method (Changes its purpose often)")
|
||||||
|
|||||||
@ -7,6 +7,13 @@ public class POI {
|
|||||||
private float Longitude;
|
private float Longitude;
|
||||||
private int CategoryID; // 0 = grünes icon(startstation) // 1 = orangenes icon(folgestationen) // 2 = rotes icon(endstation)
|
private int CategoryID; // 0 = grünes icon(startstation) // 1 = orangenes icon(folgestationen) // 2 = rotes icon(endstation)
|
||||||
|
|
||||||
|
public POI(String name, float latitude, float longitude, int categoryID) {
|
||||||
|
Name = name;
|
||||||
|
Latitude = latitude;
|
||||||
|
Longitude = longitude;
|
||||||
|
CategoryID = categoryID;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user