From fb8557d3dcdc31ac786dcfb3c5d4c6910768681a Mon Sep 17 00:00:00 2001 From: soohyeon Date: Mon, 16 Sep 2024 23:45:31 +0900 Subject: [PATCH] add :: comment --- .../meogo/domain/comment/domain/Comment.kt | 37 +++++++++++++++++++ .../comment/domain/CommentRepository.kt | 5 +++ 2 files changed, 42 insertions(+) create mode 100644 src/main/kotlin/org/meogo/domain/comment/domain/Comment.kt create mode 100644 src/main/kotlin/org/meogo/domain/comment/domain/CommentRepository.kt diff --git a/src/main/kotlin/org/meogo/domain/comment/domain/Comment.kt b/src/main/kotlin/org/meogo/domain/comment/domain/Comment.kt new file mode 100644 index 0000000..25e2051 --- /dev/null +++ b/src/main/kotlin/org/meogo/domain/comment/domain/Comment.kt @@ -0,0 +1,37 @@ +package org.meogo.domain.comment.domain + +import org.meogo.domain.post.domain.Post +import org.meogo.domain.user.domain.User +import java.time.LocalDateTime +import javax.persistence.CascadeType.REMOVE +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 + +@Entity +class Comment( + + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + val id: Long = 0, + + @Column(nullable = false) + var content: String, + + @Column(nullable = false) + val date: LocalDateTime, + + @ManyToOne(cascade = [REMOVE], fetch = FetchType.LAZY) + @JoinColumn(name = "post_id", nullable = false) + val post: Post, + + @ManyToOne(cascade = [REMOVE], fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + val user: User + +) diff --git a/src/main/kotlin/org/meogo/domain/comment/domain/CommentRepository.kt b/src/main/kotlin/org/meogo/domain/comment/domain/CommentRepository.kt new file mode 100644 index 0000000..d9b5f97 --- /dev/null +++ b/src/main/kotlin/org/meogo/domain/comment/domain/CommentRepository.kt @@ -0,0 +1,5 @@ +package org.meogo.domain.comment.domain + +import org.springframework.data.jpa.repository.JpaRepository + +interface CommentRepository : JpaRepository