diff --git a/build.gradle b/build.gradle index d7941847..81f16cc4 100644 --- a/build.gradle +++ b/build.gradle @@ -35,8 +35,8 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation "org.springframework.cloud:spring-cloud-starter-bus-kafka" implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - runtimeOnly 'com.h2database:h2' implementation 'mysql:mysql-connector-java:8.0.33' + implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '0.1.0-alpha1' // https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb implementation group: 'com.amazonaws', name: 'aws-java-sdk-dynamodb', version: '1.12.592' } diff --git a/src/main/java/kr/bb/product/entity/BaseEntity.java b/src/main/java/kr/bb/product/entity/BaseEntity.java index fcb2f03b..01505d25 100644 --- a/src/main/java/kr/bb/product/entity/BaseEntity.java +++ b/src/main/java/kr/bb/product/entity/BaseEntity.java @@ -23,4 +23,4 @@ public class BaseEntity { @Column(name = "is_deleted") private Boolean isDeleted; -} \ No newline at end of file +} diff --git a/src/main/java/kr/bb/product/entity/Category.java b/src/main/java/kr/bb/product/entity/Category.java index 19bff879..28df8bd1 100644 --- a/src/main/java/kr/bb/product/entity/Category.java +++ b/src/main/java/kr/bb/product/entity/Category.java @@ -1,5 +1,11 @@ package kr.bb.product.entity; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -8,9 +14,16 @@ @Getter @Builder -@AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Category { - private Long categoryId; +@AllArgsConstructor +@Entity +@Table(name = "category") +public class Category extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "category_id") + private Long id; + + @Column(name = "category_name") private String categoryName; } diff --git a/src/main/java/kr/bb/product/entity/Review.java b/src/main/java/kr/bb/product/entity/Review.java index 697947e0..7b2a6f0e 100644 --- a/src/main/java/kr/bb/product/entity/Review.java +++ b/src/main/java/kr/bb/product/entity/Review.java @@ -1,10 +1,14 @@ package kr.bb.product.entity; +import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.OneToMany; import javax.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -18,7 +22,7 @@ @AllArgsConstructor @Entity @Table(name = "review") -public class Review { +public class Review extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "review_id") diff --git a/src/main/java/kr/bb/product/entity/ReviewImages.java b/src/main/java/kr/bb/product/entity/ReviewImages.java index 9a7b4ea5..9874e32f 100644 --- a/src/main/java/kr/bb/product/entity/ReviewImages.java +++ b/src/main/java/kr/bb/product/entity/ReviewImages.java @@ -1,8 +1,14 @@ package kr.bb.product.entity; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; import javax.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -18,9 +24,17 @@ @Table(name = "review_images") public class ReviewImages extends BaseEntity { @Id - @Column(name = "review_id") - private Long reviewId; + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "review_images_id") + private Long id; + + @Column(name = "review_image_url") + private String reviewImageUrl; + + @ManyToOne( + fetch = FetchType.LAZY, + cascade = {CascadeType.PERSIST, CascadeType.REMOVE}) + @JoinColumn(name = "id") + private Review review; - @Column(name = "review_image") - private String reviewImage; } diff --git a/src/main/java/kr/bb/product/entity/Tag.java b/src/main/java/kr/bb/product/entity/Tag.java index b541ca4b..34b380b9 100644 --- a/src/main/java/kr/bb/product/entity/Tag.java +++ b/src/main/java/kr/bb/product/entity/Tag.java @@ -1,5 +1,11 @@ package kr.bb.product.entity; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -8,9 +14,16 @@ @Getter @Builder -@AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Tag { - private Long tagId; - private String tagName; +@AllArgsConstructor +@Entity +@Table(name = "tag") +public class Tag extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "tag_id") + private Long id; + + @Column(name = "tag_name") + private String categoryName; }