Merge branch 'develop' into frontend/timo

This commit is contained in:
Timo Volkmann 2019-05-14 08:58:27 +02:00
commit 4935298d66
5 changed files with 103 additions and 12 deletions

View File

@ -62,6 +62,15 @@ dependencies {
// https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java // https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.3.1' compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.3.1'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile group: 'org.slf4j', name:'slf4j-api', version: '1.7.2'
compile group: 'ch.qos.logback', name:'logback-classic', version: '1.0.9'
compile group: 'ch.qos.logback', name:'logback-core', version: '1.0.9'
testCompile group: 'junit', name: 'junit', version: '4.+'
} }
node { node {

View File

@ -56,8 +56,10 @@ public class Controller {
@Autowired @Autowired
TeamInviteRepository teamInviteRepository; TeamInviteRepository teamInviteRepository;
private org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Controller.class);
@PostConstruct @PostConstruct
public void init(){ public void init() {
fetchPublicKey(); fetchPublicKey();
} }
@ -333,7 +335,7 @@ public class Controller {
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json") @RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity editCache(@RequestBody Cache newCache){ public ResponseEntity editCache(@RequestBody Cache newCache) {
//---------------------- //----------------------
//Get Cache //Get Cache
@ -823,7 +825,7 @@ public class Controller {
List<TeamInvite> teamInvitesList = teamInviteRepository.findByUser(user); List<TeamInvite> teamInvitesList = teamInviteRepository.findByUser(user);
for (TeamInvite tmp : teamInvitesList){ for (TeamInvite tmp : teamInvitesList) {
tmp.setUser(null); tmp.setUser(null);
} }
@ -985,7 +987,7 @@ public class Controller {
Cache cache = (Cache) getCache.getBody(); Cache cache = (Cache) getCache.getBody();
//---------------------- //----------------------
return ResponseEntity.status(200).body(bearbeitetRepository.findByUserAndCache(user, cache)); return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetRepository.findByUserAndCache(user, cache)));
} }
@ApiOperation(value = "Returns the ranking place on the leaderboard for a specific user") @ApiOperation(value = "Returns the ranking place on the leaderboard for a specific user")
@ -1006,7 +1008,7 @@ public class Controller {
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getMyStationPOIS", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getMyStationPOIS", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getMyStationPOIS(@RequestParam String token) { public ResponseEntity getMyStationPOIS(@RequestParam String token) {
// verify user // verify user
@ -1072,7 +1074,7 @@ public class Controller {
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamOfUser(@RequestParam String token) { public ResponseEntity getTeamOfUser(@RequestParam String token) {
@ -1099,6 +1101,75 @@ public class Controller {
return ResponseEntity.status(200).body(user_info.getTeam()); return ResponseEntity.status(200).body(user_info.getTeam());
} }
@ApiOperation(value = "Returns the Team of a user")
@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 = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getCurrentStationMap", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getCurrentStationMap(@RequestParam String token, @RequestParam String cacheID) {
logger.warn("API CALL: /api/getCurrentStationMap");
// 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();
logger.debug("/api/getCurrentStationMap " + "User verificated: " + user.getEmail());
//----------------------
//Get Cache
ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
if (getCache.getStatusCodeValue() != 200) {
return getCache;
}
Cache cache = (Cache) getCache.getBody();
logger.debug("/api/getCurrentStationMap " + "Cache: " + cache.getName());
//----------------------
ResponseEntity responseBearbeitet = FinderUtil.findBearbeitetByUserAndCache(user, cache);
if (responseBearbeitet.getStatusCodeValue() != 200) {
return responseBearbeitet;
}
Bearbeitet bearbeitet = (Bearbeitet) responseBearbeitet.getBody();
logger.debug("/api/getCurrentStationMap " + "Got Bearbeitet: User: " + bearbeitet.getUser().getEmail() + " Cache: " + bearbeitet.getCache().getName());
Station nextStation = bearbeitet.getAktuelleStation();
logger.debug("/api/getCurrentStationMap " + "Got Station from bearbeitet: " + nextStation.getDescription());
int index = cache.getStationen().indexOf(nextStation);
logger.debug("/api/getCurrentStationMap " + "Index of Station " + nextStation.getDescription() + " in Cache " + cache.getName() + " : " + index);
Station lastStation = cache.getStationen().get(index - 1);
logger.debug("/api/getCurrentStationMap " + "Station before: " + lastStation.getDescription());
POI poi = new POI(cache.getName() + "_Station" + (index - 1.0), (float) lastStation.getLattitude(), (float) lastStation.getLongitude(), 201);
logger.debug("/api/getCurrentStationMap " + "Created POI: " + poi.toString());
return ResponseEntity.status(200).body(new Gson().toJson(poi));
}
@ApiOperation(value = "Test method (Changes its purpose often)") @ApiOperation(value = "Test method (Changes its purpose often)")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),

View File

@ -45,4 +45,9 @@ public class POI {
public void setCategoryID(int categoryID) { public void setCategoryID(int categoryID) {
CategoryID = categoryID; CategoryID = categoryID;
} }
@Override
public String toString() {
return "Name: " + getName() + "; Latitude " + getLatitude() + "; Longitude " + getLongitude() + "; categoryID " + getLongitude();
}
} }

View File

@ -85,12 +85,12 @@ public class CacheConstructionUtil {
return ResponseEntity.status(400).body("station fields can´t be empty"); return ResponseEntity.status(400).body("station fields can´t be empty");
} }
if (station.getLattitude() < -90 || station.getLattitude() > 90) { if (station.getLattitude() < 9 || station.getLattitude() > 10) {
return ResponseEntity.status(400).body("Lattitude has to be between -90 and 90 Degree"); return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees");
} }
if (station.getLongitude() < -180 || station.getLongitude() > 180) { if (station.getLongitude() < 49 || station.getLongitude() > 50) {
return ResponseEntity.status(400).body("Longitude has to be in the range of -180 to 180 degrees"); return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees");
} }
Random r = new Random(); Random r = new Random();

View File

@ -5,5 +5,11 @@ spring.jmx.default-domain=buga19geocaching
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jooq.sql-dialect=org.hibernate.dialect.MariaDBDialect spring.jooq.sql-dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true # spring.jpa.show-sql=true
debug=true debug=true
# logging level
logging.level.hhn.labsw.bugageocaching=DEBUG
logging.level.root=WARN