made all api methods public
This commit is contained in:
parent
47aeec7a7c
commit
67a2defe41
@ -130,7 +130,7 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/logout")
|
||||
@ResponseBody
|
||||
ResponseEntity logout(@RequestParam String token) {
|
||||
public ResponseEntity logout(@RequestParam String token) {
|
||||
// System.out.println("logout");
|
||||
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||
// System.out.println(token);
|
||||
@ -146,10 +146,10 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/createStation")
|
||||
@ResponseBody
|
||||
ResponseEntity createStation(@RequestParam String description,
|
||||
public ResponseEntity createStation(@RequestParam String description,
|
||||
@RequestParam String lattitude,
|
||||
@RequestParam String longitude,
|
||||
@RequestParam String solution) throws IllegalParameterException {
|
||||
@RequestParam String solution) {
|
||||
|
||||
if (description.length() == 0 || lattitude.length() == 0 || longitude.length() == 0 || solution.length() == 0) {
|
||||
return ResponseEntity.status(400).body("At least one Argument was empty");
|
||||
@ -196,7 +196,7 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/checkAdmin")
|
||||
@ResponseBody
|
||||
ResponseEntity checkAdmin(@RequestParam String token) {
|
||||
public ResponseEntity checkAdmin(@RequestParam String token) {
|
||||
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||
for (Role role : user.getRoles()) {
|
||||
if (role.getId() == 0) { // is admin
|
||||
@ -210,18 +210,18 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getAllStations")
|
||||
@ResponseBody
|
||||
ResponseEntity getAllStations() {
|
||||
public ResponseEntity getAllStations() {
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/createCache")
|
||||
@ResponseBody
|
||||
ResponseEntity createCache(@RequestParam String description,
|
||||
public ResponseEntity createCache(@RequestParam String description,
|
||||
@RequestParam String name,
|
||||
@RequestParam String rankingPoints,
|
||||
@RequestParam(value = "rewardID", defaultValue = "-1") String rewardID,
|
||||
@RequestParam List<Station> stationen) throws IllegalParameterException {
|
||||
@RequestParam List<Station> stationen) {
|
||||
|
||||
if (description.length() == 0 || name.length() == 0 || rankingPoints.length() == 0 || stationen.size() == 0) {
|
||||
return ResponseEntity.status(400).body("Fields can´t be empty");
|
||||
@ -271,7 +271,7 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/deleteCache")
|
||||
@ResponseBody
|
||||
ResponseEntity deleteCache(@RequestParam String cacheID) {
|
||||
public ResponseEntity deleteCache(@RequestParam String cacheID) {
|
||||
Optional<Cache> optionalCache = cacheRepository.findById(Integer.valueOf(cacheID));
|
||||
if (!optionalCache.isPresent()) {
|
||||
return ResponseEntity.status(404).body(new Gson().toJson("There is no cache with the ID " + cacheID));
|
||||
@ -299,7 +299,7 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getMyCaches")
|
||||
@ResponseBody
|
||||
ResponseEntity getMyCaches(@RequestParam String token) {
|
||||
public ResponseEntity getMyCaches(@RequestParam String token) {
|
||||
try {
|
||||
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||
if (user != null) {
|
||||
@ -322,14 +322,14 @@ public class Controller {
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getRankingList")
|
||||
@ResponseBody
|
||||
ResponseEntity getRankingList() {
|
||||
public ResponseEntity getRankingList() {
|
||||
return ResponseEntity.status(200).body(new Gson().toJson(userRepository.getRankingList()));
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||
@RequestMapping("/api/getUser")
|
||||
@ResponseBody
|
||||
ResponseEntity getUser(@RequestParam String token) {
|
||||
public ResponseEntity getUser(@RequestParam String token) {
|
||||
try {
|
||||
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||
if (user != null) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user