aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/controller
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-02-26 16:00:35 -0500
committerGunther6070 <haydenhartman10@yahoo.com>2025-02-26 16:00:35 -0500
commit72d614074a3cd578322931af647c6f0a65a23dfd (patch)
tree438a2ebaae76a4373235c369df576d4618315c38 /ufund-api/src/main/java/com/ufund/api/ufundapi/controller
parent03799f252ad2fb207e256fe7eff7ad0600131b7d (diff)
downloadJellySolutions-72d614074a3cd578322931af647c6f0a65a23dfd.tar.gz
JellySolutions-72d614074a3cd578322931af647c6f0a65a23dfd.tar.bz2
JellySolutions-72d614074a3cd578322931af647c6f0a65a23dfd.zip
Tested user http calls and fixed update user
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java27
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);
}