Ver código fonte

Add quantity to plant class

Blazej 3 anos atrás
pai
commit
4c8cb9f404

+ 3 - 0
src/main/java/com/example/plantsforyou/plant/Plant.java

@@ -20,6 +20,7 @@ public class Plant {
     private Long id;
     private String name;
     private double price;
+    private int quantity;
     @Column(columnDefinition="TEXT")
     private String description;
     @Enumerated(EnumType.STRING)
@@ -32,12 +33,14 @@ public class Plant {
 
     public Plant(String name,
                  double price,
+                 int quantity,
                  String description,
                  PlantTypeOfLight typeOfLight,
                  PlantCareDifficulty difficulty,
                  PlantSize size, boolean inStock) {
         this.name = name;
         this.price = price;
+        this.quantity = quantity;
         this.description = description;
         this.typeOfLight = typeOfLight;
         this.difficulty = difficulty;

+ 2 - 2
src/main/java/com/example/plantsforyou/plant/PlantConfig.java

@@ -16,6 +16,7 @@ public class PlantConfig {
             Plant plant = new Plant(
                     "Monstera deliciosa",
                     25.12,
+                    3,
                     "Najbardziej pożądana roślina we wnętrzach ostatnich lat, czule nazwana przez nas Grzegorzem, zawdzięcza swoją popularność nie tylko wyjątkowej urodzie, ale też swojej bezproblemowości. Monstera jest jedną z tych roślin, z którymi będziesz żyć długo i szczęśliwie.",
                     PlantTypeOfLight.diffused,
                     PlantCareDifficulty.EASY,
@@ -26,6 +27,7 @@ public class PlantConfig {
             plant = new Plant(
                     "Scindapsus pictus 'Argyraeus'",
                     59.0,
+                    4,
                     "Nie ma wielkich wymagań i zdecydowanie nadaje się dla początkujących opiekunów. Z Agatką łatwo stworzysz wrażenie gęstej dżungli. Wystarczy, że spuścisz jej pnącza kurtyną z wysokiej półki, albo belki pod sufitem.",
                     PlantTypeOfLight.direct,
                     PlantCareDifficulty.MEDIUM,
@@ -36,5 +38,3 @@ public class PlantConfig {
         };
     }
 }
-//Adding one plant to db for testing purposes
-//TODO: POST mapping GET mapping