|
|
|
|
@ -7,13 +7,10 @@ import hhn.labsw.bugageocaching.helper.POI;
|
|
|
|
|
import hhn.labsw.bugageocaching.helper.RankingListHelper;
|
|
|
|
|
import hhn.labsw.bugageocaching.helper.TeamRankingListHelper;
|
|
|
|
|
import hhn.labsw.bugageocaching.repositories.*;
|
|
|
|
|
import hhn.labsw.bugageocaching.util.CacheConstructionUtil;
|
|
|
|
|
import hhn.labsw.bugageocaching.util.FinderUtil;
|
|
|
|
|
import hhn.labsw.bugageocaching.util.VerificationUtil;
|
|
|
|
|
import io.jsonwebtoken.Claims;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiResponse;
|
|
|
|
|
import io.swagger.annotations.ApiResponses;
|
|
|
|
|
import io.swagger.annotations.*;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
@ -25,12 +22,11 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.createCacheUtil;
|
|
|
|
|
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.deleteCacheUtil;
|
|
|
|
|
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.editCacheUtil;
|
|
|
|
|
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.*;
|
|
|
|
|
import static hhn.labsw.bugageocaching.util.VerificationUtil.fetchPublicKey;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Api(value = "/api", description = "All Backend API Operations for the geocaching Application")
|
|
|
|
|
public class Controller {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
@ -67,7 +63,13 @@ public class Controller {
|
|
|
|
|
fetchPublicKey();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Retrieves all Caches, including their Stations, from the Database")
|
|
|
|
|
@ApiOperation(value = "Retrieves all Caches, including their Stations, from the Database", response = Cache.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/allCaches", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@ -78,7 +80,7 @@ public class Controller {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache")
|
|
|
|
|
@ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache", responseContainer = "ResponseEntity", response = Bearbeitet.class)
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@ -88,10 +90,10 @@ public class Controller {
|
|
|
|
|
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
|
|
|
|
@RequestMapping(value = "/api/checkStation", method = RequestMethod.PUT, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity checkStation(@RequestParam String token,
|
|
|
|
|
@RequestParam String cacheID,
|
|
|
|
|
@RequestParam String stationID,
|
|
|
|
|
@RequestParam String durchgefuehrterCacheID) {
|
|
|
|
|
public ResponseEntity checkStation(@ApiParam(value = "JWT Token indentifiying the cser", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The CacheID from the scanned QR Code", required = true) @RequestParam String cacheID,
|
|
|
|
|
@ApiParam(value = "The StationID from the scanned QR Code", required = true) @RequestParam String stationID,
|
|
|
|
|
@ApiParam(value = "The CacheID from the cache the user does at the time scanning the code", required = true)@RequestParam String durchgefuehrterCacheID) {
|
|
|
|
|
//----------------------
|
|
|
|
|
//Verify token
|
|
|
|
|
ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
|
|
|
|
|
@ -233,45 +235,49 @@ public class Controller {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Creates a new Cache")
|
|
|
|
|
@ApiOperation(value = "Creates a new Cache", response = String.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 400, message = "Something wrong with the given Parameters")
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/createCache", method = RequestMethod.POST, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity createCache(@RequestBody Cache cache) {
|
|
|
|
|
public ResponseEntity createCache(@ApiParam(value = "The cache to be created and saved in the database", required = true) @RequestBody Cache cache) {
|
|
|
|
|
logger.warn("API CALL: api/createCache");
|
|
|
|
|
logger.debug("/api/allCaches PARAMETERS:\ncache: " + cache.getName());
|
|
|
|
|
return createCacheUtil(cache);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Edits a Cache")
|
|
|
|
|
@ApiOperation(value = "Edits a Cache", responseContainer = "Body of ResponseEntity", response = String.class)
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@ApiResponse(code = 401, message = "JWT Token expired"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Something wrong with the given Parameters")
|
|
|
|
|
@ApiResponse(code = 400, message = "Something went wrong at verification")
|
|
|
|
|
})
|
|
|
|
|
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
|
|
|
|
|
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity editCache(@RequestBody Cache newCache) {
|
|
|
|
|
public ResponseEntity editCache(@ApiParam(value = "The edited cache", required = true) @RequestBody Cache newCache) {
|
|
|
|
|
logger.warn("API CALL: /api/editCache");
|
|
|
|
|
logger.debug("/api/editCache PARAMETERS:\nnewCache: " + newCache.getName());
|
|
|
|
|
return editCacheUtil(newCache);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Checks if the given User has an admin role")
|
|
|
|
|
@ApiOperation(value = "Checks if the given User has an admin role", response = Boolean.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/checkAdmin", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity checkAdmin(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity checkAdmin(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -299,9 +305,12 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(401).body(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns all Stations")
|
|
|
|
|
@ApiOperation(value = "Returns all Stations", response = Station.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error")
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getAllStations", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ -312,29 +321,33 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Deletes a Cache")
|
|
|
|
|
@ApiOperation(value = "Deletes a Cache", responseContainer = "Body of ResponseEntity", response = Boolean.class)
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error")
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/deleteCache", method = {RequestMethod.DELETE}, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity deleteCache(@RequestParam String cacheID) {
|
|
|
|
|
public ResponseEntity deleteCache(@ApiParam(value = "The cache ID to be deleted", required = true) @RequestParam String cacheID) {
|
|
|
|
|
logger.warn("API CALL: /api/deleteCache");
|
|
|
|
|
logger.debug("/api/deleteCache: PARAMETERS:\ncacheID: " + cacheID);
|
|
|
|
|
return deleteCacheUtil(cacheID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns all Caches finished/started by a given User")
|
|
|
|
|
@ApiOperation(value = "Returns all Caches finished/started by a given User", response = Bearbeitet.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getMyCaches", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity getMyCaches(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity getMyCaches(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
|
|
|
|
|
logger.warn("API CALL: /api/getMyCaches");
|
|
|
|
|
logger.debug("/api/getMyCaches: PARAMETERS:\ntoken: " + token);
|
|
|
|
|
@ -375,14 +388,17 @@ public class Controller {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns the rankinglist")
|
|
|
|
|
@ApiOperation(value = "Returns the rankinglist", response = RankingListHelper.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error")
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getRankingList", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity getRankingList(@RequestParam(value = "token", defaultValue = "null") String token) {
|
|
|
|
|
public ResponseEntity getRankingList(@ApiParam(value = "JWT Token indentifiying the User", required = false) @RequestParam(value = "token", defaultValue = "null") String token) {
|
|
|
|
|
|
|
|
|
|
logger.warn("API CALL: /api/getRankingList");
|
|
|
|
|
logger.debug("/api/getRankingList: PARAMETERS: -");
|
|
|
|
|
@ -401,7 +417,7 @@ public class Controller {
|
|
|
|
|
logger.debug("/api/getRankingList Converted Objects to RankingListHelper");
|
|
|
|
|
logger.debug("/api/getRankingList RankingList: " + new GsonBuilder().setPrettyPrinting().create().toJson(sendBackUsers));
|
|
|
|
|
|
|
|
|
|
if(!token.equals("null")) {
|
|
|
|
|
if (!token.equals("null")) {
|
|
|
|
|
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
@ -422,16 +438,16 @@ public class Controller {
|
|
|
|
|
User user = (User) getUser.getBody();
|
|
|
|
|
|
|
|
|
|
boolean userAlreadyInRankingList = false;
|
|
|
|
|
for (RankingListHelper rankingListHelper: sendBackUsers) {
|
|
|
|
|
for (RankingListHelper rankingListHelper : sendBackUsers) {
|
|
|
|
|
logger.debug("RankingList Helper " + rankingListHelper.getUsername());
|
|
|
|
|
logger.debug("User: " + user.getUsername());
|
|
|
|
|
if(rankingListHelper.getUsername().equals(user.getEmail())){
|
|
|
|
|
if (rankingListHelper.getUsername().equals(user.getEmail())) {
|
|
|
|
|
userAlreadyInRankingList = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!userAlreadyInRankingList) {
|
|
|
|
|
if (!userAlreadyInRankingList) {
|
|
|
|
|
ResponseEntity singlePlace = getRankingPlace(user.getEmail());
|
|
|
|
|
|
|
|
|
|
if (singlePlace.getStatusCodeValue() == 200) {
|
|
|
|
|
@ -444,9 +460,12 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns the Team Rankinglist")
|
|
|
|
|
@ApiOperation(value = "Returns the Team Rankinglist", response = TeamRankingListHelper.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error")
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getTeamRankingList", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ -472,16 +491,17 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns a user from a given token")
|
|
|
|
|
@ApiOperation(value = "Returns a user from a given token", response = User.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getUser", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity getUser(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity getUser(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
|
|
|
|
|
logger.warn("API CALL: /api/getUser");
|
|
|
|
|
logger.debug("/api/getUser: PARAMETERS:\ntoken: " + token);
|
|
|
|
|
@ -518,17 +538,18 @@ public class Controller {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Creates a new Team")
|
|
|
|
|
@ApiOperation(value = "Creates a new Team", response = Team.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/createTeam", method = RequestMethod.POST, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity createTeam(@RequestParam String token,
|
|
|
|
|
@RequestParam String name) {
|
|
|
|
|
public ResponseEntity createTeam(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "Name of the team to be created", required = true) @RequestParam String name) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -573,17 +594,18 @@ public class Controller {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------
|
|
|
|
|
@ApiOperation(value = "Lets the user join a Team")
|
|
|
|
|
@ApiOperation(value = "Lets the user join a Team", response = Team.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/joinTeam", method = RequestMethod.PUT, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity joinTeam(@RequestParam String token,
|
|
|
|
|
@RequestParam String teamID) {
|
|
|
|
|
public ResponseEntity joinTeam(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "Team id of the team the user wants to join", required = true) @RequestParam String teamID) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -644,16 +666,17 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(team));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Removes the user from the Team")
|
|
|
|
|
@ApiOperation(value = "Removes the user from the Team", responseContainer = "Body of ResponseEntity", response = String.class)
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/leaveTeam", method = {RequestMethod.PUT, RequestMethod.GET}, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity leaveTeam(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity leaveTeam(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
@ -715,17 +738,18 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body("Ok");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Sends a Team Invite to the invitedUserEmail from the User (token)")
|
|
|
|
|
@ApiOperation(value = "Sends a Team Invite to the invitedUserEmail from the User (token)", responseContainer = "Body of ResponseEntity", response = String.class)
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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
|
|
|
|
|
@RequestMapping(value = "/api/sendTeamInvite", method = RequestMethod.POST, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity sendTeamInvite(@RequestParam String token,
|
|
|
|
|
@RequestParam String invitedUserEmail) {
|
|
|
|
|
public ResponseEntity sendTeamInvite(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The email of the invited User", required = true)@RequestParam String invitedUserEmail) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -787,16 +811,17 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body("OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns all User invites for a specific User")
|
|
|
|
|
@ApiOperation(value = "Returns all User invites for a specific User", response = TeamInvite.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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
|
|
|
|
|
@RequestMapping(value = "/api/getMyTeamInvites", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity getMyTeamInvites(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity getMyTeamInvites(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -833,17 +858,18 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(teamInvitesList));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Removes a team invite from a user (called if a user declined a team invite)")
|
|
|
|
|
@ApiOperation(value = "Removes a team invite from a user (called if a user declined a team invite)", response = String.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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
|
|
|
|
|
@RequestMapping(value = "/api/deleteTeamInvite", method = RequestMethod.DELETE, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity deleteTeamInvite(@RequestParam String token,
|
|
|
|
|
@RequestParam String teamInviteID) {
|
|
|
|
|
public ResponseEntity deleteTeamInvite(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The id of the TeamInvite to be deletd", required = true) @RequestParam String teamInviteID) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -865,17 +891,18 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body("OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Sets the team status")
|
|
|
|
|
@ApiOperation(value = "Sets the team status", responseContainer = "Body of ResponseEntity", response = String.class)
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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
|
|
|
|
|
@RequestMapping(value = "/api/setTeamStatus", method = RequestMethod.PUT, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity setTeamStatus(@RequestParam String token,
|
|
|
|
|
@RequestParam String teamStatus) {
|
|
|
|
|
public ResponseEntity setTeamStatus(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The new team status", required = true) @RequestParam String teamStatus) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -916,39 +943,46 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(teamStatus));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns a team by a name")
|
|
|
|
|
@ApiOperation(value = "Returns a team by a name", response = Team.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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
|
|
|
|
|
@RequestMapping(value = "/api/getTeam", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
public ResponseEntity getTeam(@RequestParam String name) {
|
|
|
|
|
public ResponseEntity getTeam(@ApiParam(value = "The name of the team", required = true) @RequestParam String name) {
|
|
|
|
|
ResponseEntity responseEntity = FinderUtil.findTeamByName(name);
|
|
|
|
|
|
|
|
|
|
return responseEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns all teammembers by the team name")
|
|
|
|
|
@ApiOperation(value = "Returns all teammembers by the team name", response = User.class, responseContainer = "List in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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
|
|
|
|
|
@RequestMapping(value = "/api/getTeamMembers", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
public ResponseEntity getTeamMembers(@RequestParam String name) {
|
|
|
|
|
public ResponseEntity getTeamMembers(@ApiParam(value = "The name of the team") @RequestParam String name) {
|
|
|
|
|
return FinderUtil.findTeammemberByTeamName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns the station the user is currently at (for a specific cache)")
|
|
|
|
|
@ApiOperation(value = "Returns the station the user is currently at (for a specific cache)", response = Station.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getCurrentStation", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ResponseEntity getStationFromUserAndCache(@RequestParam String token,
|
|
|
|
|
@RequestParam String cacheID) {
|
|
|
|
|
public ResponseEntity getStationFromUserAndCache(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The Cache id for the searched station", required = true) @RequestParam String cacheID) {
|
|
|
|
|
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
@ -982,27 +1016,29 @@ public class Controller {
|
|
|
|
|
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", response = Integer.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getRankingPlace", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
public ResponseEntity getRankingPlace(@RequestParam String email) {
|
|
|
|
|
public ResponseEntity getRankingPlace(@ApiParam(value = "The email of the user as unique identifier", required = true)@RequestParam String email) {
|
|
|
|
|
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(email));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns startstations and all other stations the user already visited as POIS")
|
|
|
|
|
@ApiOperation(value = "Returns startstations and all other stations the user already visited as POIS", response = POI.class, responseContainer = "Array in Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getMyStationPOIS", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
public ResponseEntity getMyStationPOIS(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity getMyStationPOIS(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
|
|
|
|
|
@ -1060,15 +1096,16 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(pois));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns the Team of a user")
|
|
|
|
|
@ApiOperation(value = "Returns the Team of a user", response = Team.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
public ResponseEntity getTeamOfUser(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity getTeamOfUser(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
@ -1093,15 +1130,17 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(user_info.getTeam());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Returns the Team of a user")
|
|
|
|
|
@ApiOperation(value = "Returns the Team of a user", response = POI.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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) {
|
|
|
|
|
public ResponseEntity getCurrentStationMap(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "Cache id of the searched station", required = true) @RequestParam String cacheID) {
|
|
|
|
|
|
|
|
|
|
logger.warn("API CALL: /api/getCurrentStationMap");
|
|
|
|
|
|
|
|
|
|
@ -1162,15 +1201,16 @@ public class Controller {
|
|
|
|
|
return ResponseEntity.status(200).body(new Gson().toJson(poi));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Resets the rankinglist")
|
|
|
|
|
@ApiOperation(value = "Resets the rankinglist", response = HttpStatus.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/resetRankingList", method = RequestMethod.GET, produces = "application/json")
|
|
|
|
|
public ResponseEntity resetRankingList(@RequestParam String token) {
|
|
|
|
|
public ResponseEntity resetRankingList(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
|
|
|
|
|
logger.warn("API CALL: /api/resetRankingList");
|
|
|
|
|
|
|
|
|
|
// verify user
|
|
|
|
|
@ -1216,15 +1256,17 @@ public class Controller {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Deletes the bearbeitet entry from a User from a Cache")
|
|
|
|
|
@ApiOperation(value = "Deletes the bearbeitet entry from a User from a Cache", response = String.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/deleteCacheForUser", method = RequestMethod.DELETE, produces = "application/json")
|
|
|
|
|
public ResponseEntity deleteCacheForUser(@RequestParam String token, @RequestParam String cacheID) {
|
|
|
|
|
public ResponseEntity deleteCacheForUser(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The cache id for the cache to be deleted", required = true) @RequestParam String cacheID) {
|
|
|
|
|
|
|
|
|
|
logger.warn("API CALL: /api/deleteCacheForUser");
|
|
|
|
|
// verify user
|
|
|
|
|
@ -1284,15 +1326,17 @@ public class Controller {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "Resets the points of a single User ")
|
|
|
|
|
@ApiOperation(value = "Resets the points of a single User", response = HttpStatus.class, responseContainer = "Body of ResponseEntity")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@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/resetSingleUser", method = RequestMethod.PUT, produces = "application/json")
|
|
|
|
|
public ResponseEntity resetSingleUser(@RequestParam String token, @RequestParam String username) {
|
|
|
|
|
public ResponseEntity resetSingleUser(@ApiParam(value = "JWT Token indentifiying the User (Admin in this case)", required = true) @RequestParam String token,
|
|
|
|
|
@ApiParam(value = "The username of the user to be reseted", required = true) @RequestParam String username) {
|
|
|
|
|
logger.debug("API CALL: /api/resetSingleUser");
|
|
|
|
|
// verify user
|
|
|
|
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
|
|
|
|
@ -1326,7 +1370,7 @@ public class Controller {
|
|
|
|
|
User deleteUser = userRepository.findByEmail(username);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(deleteUser == null) {
|
|
|
|
|
if (deleteUser == null) {
|
|
|
|
|
return ResponseEntity.status(400).body("Es wurde kein User mit dieser Email gefunden.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1348,6 +1392,7 @@ public class Controller {
|
|
|
|
|
@ApiOperation(value = "Test method (Changes its purpose often)")
|
|
|
|
|
@ApiResponses(value = {
|
|
|
|
|
@ApiResponse(code = 404, message = "Database error"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
|
|
|
|
|
@ApiResponse(code = 401, message = "JWT Token expired"),
|
|
|
|
|
@ApiResponse(code = 400, message = "Something went wrong at verification")
|
|
|
|
|
})
|
|
|
|
|
|