diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-07 00:02:56 -0500 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-07 00:02:56 -0500 |
commit | 34903015992ac0cd7719b662af3ceb54a801351c (patch) | |
tree | 322e5477a5d251f85d9b9ef193fac26374319a4b /ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | |
parent | a3fbcd713ae9a6b3f38dcc42a5c4c2f369a5d6f5 (diff) | |
download | JellySolutions-34903015992ac0cd7719b662af3ceb54a801351c.tar.gz JellySolutions-34903015992ac0cd7719b662af3ceb54a801351c.tar.bz2 JellySolutions-34903015992ac0cd7719b662af3ceb54a801351c.zip |
Finish update methods
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index 15a741a..7773028 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -1,6 +1,7 @@ package com.ufund.api.ufundapi.controller; import java.io.IOException; +import java.security.InvalidParameterException; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -141,15 +142,17 @@ public class CupboardController { * @param need The need to update * @return OK response and the need if it was successful, or INTERNAL_SERVER_ERROR if there was an issue */ - @PutMapping("") - public ResponseEntity<Need> updateNeed(@RequestBody Need need) { + @PutMapping("/{id}") + public ResponseEntity<Need> updateNeed(@RequestBody Need need, @PathVariable int id) { try { - Need updatedNeed = cupboardService.updateNeed(need); + Need updatedNeed = cupboardService.updateNeed(need, id); if (updatedNeed != null) { return new ResponseEntity<>(need, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } + } catch (InvalidParameterException ex) { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } catch (IOException e) { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } |