diff options
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java index ae75179..1af865d 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java @@ -19,13 +19,13 @@ import com.ufund.api.ufundapi.model.User; import com.ufund.api.ufundapi.persistence.UserDAO; @RestController -@RequestMapping("cupboard") +@RequestMapping("users") public class UserController { private static final Logger LOG = Logger.getLogger(CupboardController.class.getName()); private final UserDAO UserDAO; /** - * Create a cupboard controller to receive REST signals + * Create a user controller to receive REST signals * * @param UserDAO The Data Access Object */ @@ -37,7 +37,8 @@ public class UserController { * Creates a User with the provided object * * @param user The user to create - * @return OK response and the user if it was successful, INTERNAL_SERVER_ERROR otherwise + * @return OK response and the user if it was successful, INTERNAL_SERVER_ERROR + * otherwise */ @PostMapping("") public ResponseEntity<User> createUser(@RequestBody User user) { @@ -47,7 +48,7 @@ public class UserController { } else { return new ResponseEntity<>(HttpStatus.CONFLICT); } - + } catch (IOException ex) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } @@ -107,18 +108,19 @@ public class UserController { * Updates a User with the provided one * * @param user The user to update - * @return OK response and the user if it was successful, or INTERNAL_SERVER_ERROR if there was an issue + * @return OK response and the user if it was successful, or + * INTERNAL_SERVER_ERROR if there was an issue */ - @PutMapping("") - public ResponseEntity<User> updateUser(@RequestBody User user, String string) { + @PutMapping("/{name}") + public ResponseEntity<User> updateUser(@RequestBody User user, @PathVariable String name) { try { - user = UserDAO.updateUser(user, string); + user = UserDAO.updateUser(user, name); if (user != null) { return new ResponseEntity<>(user, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - + } catch (IOException e) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } @@ -128,8 +130,9 @@ public class UserController { * Deletes a user with the desired name * * @param name The name of the user - * @return OK if the user was deleted, NOT_FOUND if the user was not found, or INTERNAL_SERVER_ERROR if an error occurred - */ + * @return OK if the user was deleted, NOT_FOUND if the user was not found, or + * INTERNAL_SERVER_ERROR if an error occurred + */ @DeleteMapping("/{name}") public ResponseEntity<User> deleteUser(@PathVariable String name) { try { @@ -137,7 +140,7 @@ public class UserController { return new ResponseEntity<>(HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } + } } catch (IOException e) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } |