Explorar o código

Add price and in_stock variables to plant

Blazej %!s(int64=4) %!d(string=hai) anos
pai
achega
fca0c6db45

+ 7 - 4
src/main/java/com/example/plantsforyou/plant/Plant.java

@@ -20,6 +20,7 @@ public class Plant {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
     private String name;
+    private double price;
     @Column(columnDefinition="TEXT")
     private String description;
     @Enumerated(EnumType.STRING)
@@ -28,18 +29,20 @@ public class Plant {
     private PlantCareDifficulty difficulty;
     @Enumerated(EnumType.STRING)
     private PlantSize size;
+    boolean in_stock;
 
     public Plant(String name,
+                 double price,
                  String description,
                  PlantTypeOfLight typeOfLight,
                  PlantCareDifficulty difficulty,
-                 PlantSize size) {
+                 PlantSize size, boolean in_stock) {
         this.name = name;
+        this.price = price;
         this.description = description;
         this.typeOfLight = typeOfLight;
         this.difficulty = difficulty;
         this.size = size;
+        this.in_stock = in_stock;
     }
-}
-//TODO Add price and update price method in service
-// Maybe in-stock boolean?
+}

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

@@ -15,10 +15,12 @@ public class PlantConfig {
         return args -> {
             Plant plant = new Plant(
                     "Monstera deliciosa",
+                    25.12,
                     "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,
-                    PlantSize.MEDIUM
+                    PlantSize.MEDIUM,
+                    true
             );
             repository.save(plant);
         };