Просмотр исходного кода

Add PlantConfig to save one plant to db for testing

Blazej 4 лет назад
Родитель
Сommit
11860c4010
1 измененных файлов с 28 добавлено и 0 удалено
  1. 28 0
      src/main/java/com/example/plantsforyou/plant/PlantConfig.java

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

@@ -0,0 +1,28 @@
+package com.example.plantsforyou.plant;
+
+
+import com.example.plantsforyou.plant.enums.PlantCareDifficulty;
+import com.example.plantsforyou.plant.enums.PlantSize;
+import com.example.plantsforyou.plant.enums.PlantTypeOfLight;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class PlantConfig {
+    @Bean
+    CommandLineRunner commandLineRunner(PlantRepository repository){
+        return args -> {
+            Plant plant = new Plant(
+                    "Monstera deliciosa",
+                    "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
+            );
+            repository.save(plant);
+        };
+    }
+}
+//Adding one plant to db for testing purposes
+//TODO: POST mapping GET mapping