diff options
| author | Tyler Ferrari <69283684+Sowgro@users.noreply.github.com> | 2025-02-16 14:52:42 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-16 14:52:42 -0500 | 
| commit | a1d20cdc20158cc14404dd4cbc7fe52640a0a2dc (patch) | |
| tree | baef036b5028a222bb046ce2b4e45226a356d197 | |
| parent | 61663465d01fcec6d259ecf393fae2668823a527 (diff) | |
| parent | c5455e51a289a7d1ccdf42fe3b145aa1a3135241 (diff) | |
| download | JellySolutions-a1d20cdc20158cc14404dd4cbc7fe52640a0a2dc.tar.gz JellySolutions-a1d20cdc20158cc14404dd4cbc7fe52640a0a2dc.tar.bz2 JellySolutions-a1d20cdc20158cc14404dd4cbc7fe52640a0a2dc.zip  | |
Merge pull request #4 from RIT-SWEN-261-02/search-need
Merge search-needs to main
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 23 | 
1 files changed, 21 insertions, 2 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 8af3fee..3b99117 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 @@ -55,9 +55,28 @@ public class CupboardController {          }      } +     /** +     * Responds to the GET request for all {@linkplain Need need} whose name contains +     * the text in name +     *  +     * @param name The name parameter which contains the text used to find the {@link Need need} +     *  +     * @return ResponseEntity with array of {@link Need need} objects (may be empty) and +     * HTTP status of OK<br> +     * ResponseEntity with HTTP status of INTERNAL_SERVER_ERROR otherwise +     * <p> +     */      @GetMapping("/") -    public Need searchNeeds(@RequestParam String name) { -        return cupboard.findNeeds(name); +    public ResponseEntity<Need[]> searchNeeds(@RequestParam String name) { +        LOG.info("GET /need/?name="+name); + +        try { +            Need[] needArray = cupboard.findNeeds(name); +            return new ResponseEntity<Need[]>(needArray,HttpStatus.OK); +        } catch (IOException e) { +            LOG.log(Level.SEVERE,e.getLocalizedMessage()); +            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); +        }      }      @GetMapping("/{id}")  | 
