Skip to content

Commit

Permalink
add :: comment
Browse files Browse the repository at this point in the history
  • Loading branch information
meltapplee committed Sep 16, 2024
1 parent 0b0c764 commit fb8557d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/kotlin/org/meogo/domain/comment/domain/Comment.kt
Original file line number Diff line number Diff line change
@@ -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

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.meogo.domain.comment.domain

import org.springframework.data.jpa.repository.JpaRepository

interface CommentRepository : JpaRepository<Comment, Long>

0 comments on commit fb8557d

Please sign in to comment.