diff options
| author | benal01 <bja4245@rit.edu> | 2025-03-31 17:47:09 -0400 | 
|---|---|---|
| committer | benal01 <bja4245@rit.edu> | 2025-03-31 17:47:09 -0400 | 
| commit | 371caf37fb71fd9adf89e52a5557a9359d680539 (patch) | |
| tree | dfb4a308845f8cfdee62f7d30f30a59dca138999 | |
| parent | ab07239e9daa1d86f89fc53a8ad5beb6c580c517 (diff) | |
| download | JellySolutions-371caf37fb71fd9adf89e52a5557a9359d680539.tar.gz JellySolutions-371caf37fb71fd9adf89e52a5557a9359d680539.tar.bz2 JellySolutions-371caf37fb71fd9adf89e52a5557a9359d680539.zip  | |
backend image support
3 files changed, 12 insertions, 5 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 ea86aa8..d448f6c 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,6 +55,7 @@ public class CupboardController {          LOG.log(Level.INFO, "POST /cupboard body={0}", params);          String name = (String) params.get("name"); +        String image = (String) params.get("image");          String location = (String) params.get("location");          double maxGoal = ((Number) params.get("maxGoal")).doubleValue();          boolean urgent = (Boolean) params.get("urgent"); @@ -63,7 +64,7 @@ public class CupboardController {          try {              authService.keyHasAccessToCupboard(key); -            Need need = cupboardService.createNeed(name, location, maxGoal, goalType, urgent, description); +            Need need = cupboardService.createNeed(name, image, location, maxGoal, goalType, urgent, description);              return new ResponseEntity<>(need, HttpStatus.OK);          } catch (DuplicateKeyException ex) {              LOG.log(Level.WARNING, ex.getLocalizedMessage()); diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java index 35e81b3..9b6170b 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java @@ -10,6 +10,7 @@ public class Need {      }      @JsonProperty("name") private String name; +    @JsonProperty("image") private String image;      @JsonProperty("location") private String location;      @JsonProperty("id") private int id;      @JsonProperty("filterAttributes") private String[] filterAttributes; @@ -30,8 +31,9 @@ public class Need {       * @param urgent The urgency of the need       * @param description The description of the need       */ -    public Need(@JsonProperty("name") String name, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent, @JsonProperty("Description") String description) { +    public Need(@JsonProperty("name") String name, @JsonProperty("image") String image, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent, @JsonProperty("Description") String description) {          this.id = id; +        this.image = image;          this.location = location;          this.name = name;          this.maxGoal = maxGoal; @@ -44,14 +46,16 @@ public class Need {       * Create a new need       *       * @param name    The name of the need +     * @param image   The image representation of the need       * @param location The location of the need       * @param maxGoal The maximum goal for this need       * @param type    The type of need (monetary, physical)       * @param urgent The urgency of the need       * @param description The description of the need       */ -    public Need(String name, String location, double maxGoal, GoalType type, boolean urgent, String description) { +    public Need(String name, String image, String location, double maxGoal, GoalType type, boolean urgent, String description) {          this.name = name; +        this.image = image;          this.location = location;          this.type = type;          this.maxGoal = maxGoal; @@ -66,6 +70,7 @@ public class Need {       */      public Need(Need other) {          this.name = other.name; +        this.image = other.image;          this.location = other.location;          this.id = other.id;          this.filterAttributes = other.filterAttributes; diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index d216b01..0652696 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -25,6 +25,7 @@ public class CupboardService {       * Creates a new Need       *       * @param name The name of the need to create +     * @param image The image representation of the need to create       * @param location The location of the new need       * @param maxGoal The max goal of the new need       * @param goalType The goal type of the new need @@ -34,7 +35,7 @@ public class CupboardService {       * @throws IOException Thrown if there was any issue saving the data       * @throws DuplicateKeyException If there already exists a need with the same name       */ -    public Need createNeed(String name, String location, double maxGoal, Need.GoalType goalType, boolean urgent, String description) throws IOException, DuplicateKeyException { +    public Need createNeed(String name, String image, String location, double maxGoal, Need.GoalType goalType, boolean urgent, String description) throws IOException, DuplicateKeyException {          if (maxGoal <= 0) {              throw new IllegalArgumentException("Max Goal must be greater than zero"); @@ -46,7 +47,7 @@ public class CupboardService {              }          } -        Need need = new Need(name, location, maxGoal, goalType, urgent, description); +        Need need = new Need(name, image, location, maxGoal, goalType, urgent, description);          return cupboardDAO.addNeed(need);      }  | 
