Changed get my Station POIS Method

This commit is contained in:
Maximilian Leopold 2019-05-08 14:19:04 +02:00
parent 2c7d47e0f0
commit 1d3bd11331
2 changed files with 20 additions and 13 deletions

View File

@ -1008,22 +1008,26 @@ public class Controller {
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 = 201;
} else { // is endstation
categoryID = 203;
for (Bearbeitet bearbeitet : bearbeitetRepository.findByUser(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 = 201;
if (i == index) {
POI poi = new POI(cache.getName() + "_Station" + (i + 1), (float) station.getLattitude(), (float) station.getLongitude(), categoryID);
poisList.add(poi);
}
} else { // is endstation
categoryID = 203;
POI poi = new POI(cache.getName() + "_Station" + (i + 1), (float) station.getLattitude(), (float) station.getLongitude(), categoryID);
poisList.add(poi);
}
//POI poi = new POI(cache.getName() + "_Station" + (i + 1), (float) station.getLattitude(), (float) station.getLongitude(), categoryID);
//poisList.add(poi);
}
}
@ -1042,7 +1046,7 @@ public class Controller {
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamOfUser(@RequestParam String token){
public ResponseEntity getTeamOfUser(@RequestParam String token) {
// verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);

View File

@ -6,6 +6,9 @@ import hhn.labsw.bugageocaching.entities.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface BearbeitetRepository extends JpaRepository<Bearbeitet, Integer> {
Bearbeitet findByUserAndCache(User user, Cache cache);
List<Bearbeitet> findByUser(User user);
}