Ver código fonte

Create Plant class with required enums PlantTypeOfLight PlantSize PlantCareDifficulty

Blazej 4 anos atrás
pai
commit
e0fddd4795

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

@@ -0,0 +1,45 @@
+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 lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.springframework.context.annotation.Description;
+
+import javax.persistence.*;
+
+@Getter
+@Setter
+@NoArgsConstructor
+@Entity
+public class Plant {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+    private String name;
+    @Column(columnDefinition="TEXT")
+    private String description;
+    @Enumerated(EnumType.STRING)
+    private PlantTypeOfLight typeOfLight;
+    @Enumerated(EnumType.STRING)
+    private PlantCareDifficulty difficulty;
+    @Enumerated(EnumType.STRING)
+    private PlantSize size;
+
+    public Plant(String name,
+                 String description,
+                 PlantTypeOfLight typeOfLight,
+                 PlantCareDifficulty difficulty,
+                 PlantSize size) {
+        this.name = name;
+        this.description = description;
+        this.typeOfLight = typeOfLight;
+        this.difficulty = difficulty;
+        this.size = size;
+    }
+}
+//TODO Add price and update price method in service
+// Maybe in-stock boolean?

+ 9 - 0
src/main/java/com/example/plantsforyou/plant/enums/PlantCareDifficulty.java

@@ -0,0 +1,9 @@
+package com.example.plantsforyou.plant.enums;
+
+public enum PlantCareDifficulty {
+    VERY_EASY,
+    EASY,
+    MEDIUM,
+    HARD,
+    VERY_HARD
+}

+ 7 - 0
src/main/java/com/example/plantsforyou/plant/enums/PlantSize.java

@@ -0,0 +1,7 @@
+package com.example.plantsforyou.plant.enums;
+
+public enum PlantSize {
+    SMALL,
+    MEDIUM,
+    BIG
+}

+ 7 - 0
src/main/java/com/example/plantsforyou/plant/enums/PlantTypeOfLight.java

@@ -0,0 +1,7 @@
+package com.example.plantsforyou.plant.enums;
+
+public enum PlantTypeOfLight {
+    direct,
+    diffused,
+    shadow
+}