Skip to content

Commit

Permalink
Small Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsadeghpour committed Feb 25, 2022
1 parent 61ab98a commit d268674
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ResponseEntity<List<User>> getAllUsers(@RequestParam(required = false) St
}
}

@GetMapping("/{id}")
@GetMapping("/users/{id}")
public ResponseEntity<User> getUserById(@PathVariable("id") String id) {
try {
Optional<User> userData = userRepository.findById(id);
Expand All @@ -50,7 +50,7 @@ public ResponseEntity<User> getUserById(@PathVariable("id") String id) {
}
}

@PostMapping("/")
@PostMapping("/users")
public ResponseEntity<User> createUser(@RequestBody User user) {
try {
User newUser = createNewUser(user);
Expand All @@ -61,7 +61,7 @@ public ResponseEntity<User> createUser(@RequestBody User user) {
}
}

@PutMapping("/{id}")
@PutMapping("/users/{id}")
public ResponseEntity<User> updateUser(@PathVariable("id") String id, @RequestBody User user) {
try {
Optional<User> userData = userRepository.findById(id);
Expand All @@ -75,7 +75,7 @@ public ResponseEntity<User> updateUser(@PathVariable("id") String id, @RequestBo
}
}

@DeleteMapping("/{id}")
@DeleteMapping("/users/{id}")
public ResponseEntity<HttpStatus> deleteUser(@PathVariable("id") String id) {
try {
userRepository.deleteById(id);
Expand All @@ -85,7 +85,7 @@ public ResponseEntity<HttpStatus> deleteUser(@PathVariable("id") String id) {
}
}

@DeleteMapping("/")
@DeleteMapping("/users")
public ResponseEntity<HttpStatus> deleteAllUsers() {
try {
userRepository.deleteAll();
Expand Down

0 comments on commit d268674

Please sign in to comment.