added getUser API method
This commit is contained in:
parent
61330b3f0b
commit
cd3508090b
@ -290,7 +290,8 @@ public class Controller {
|
|||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping("/api/getMyCaches")
|
@RequestMapping("/api/getMyCaches")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String getMyCaches(@RequestParam String token) {
|
ResponseEntity getMyCaches(@RequestParam String token) {
|
||||||
|
try {
|
||||||
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||||
ArrayList<Bearbeitet> bearbeitetList = new ArrayList<>();
|
ArrayList<Bearbeitet> bearbeitetList = new ArrayList<>();
|
||||||
|
|
||||||
@ -299,14 +300,29 @@ public class Controller {
|
|||||||
bearbeitetList.add(bearbeitet);
|
bearbeitetList.add(bearbeitet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Gson().toJson(bearbeitetList);
|
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetList));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(404).body("User was not found in the database");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
|
||||||
@RequestMapping("/api/getRankingList")
|
@RequestMapping("/api/getRankingList")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String getRankingList() {
|
ResponseEntity getRankingList() {
|
||||||
return new Gson().toJson(userRepository.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) {
|
||||||
|
try {
|
||||||
|
User user = userRepository.findByUsername(token.substring(0, token.indexOf("$")));
|
||||||
|
return ResponseEntity.status(200).body(new Gson().toJson(user));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(404).body("User was not found in the database");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user