diff --git a/core/src/main/kotlin/com/usw/usgo/domain/BaseEntity.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/BaseEntity.kt similarity index 72% rename from core/src/main/kotlin/com/usw/usgo/domain/BaseEntity.kt rename to core/src/main/kotlin/com/usw/usgo/domain/core/BaseEntity.kt index 8acc516..3ca0c85 100644 --- a/core/src/main/kotlin/com/usw/usgo/domain/BaseEntity.kt +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/BaseEntity.kt @@ -1,4 +1,4 @@ -package com.usw.usgo.domain +package com.usw.usgo.domain.core import jakarta.persistence.* import org.springframework.data.annotation.CreatedDate @@ -11,12 +11,16 @@ import java.time.LocalDateTime abstract class BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long? = null + val id: Long = 0L + + @Column(name = "is_deleted") + var isDeleted: Boolean = false @CreatedDate - @Column(updatable = false) + @Column(name = "created_at", updatable = false) val createdAt: LocalDateTime = LocalDateTime.now() @LastModifiedDate + @Column(name = "modified_at") var modifiedAt: LocalDateTime = LocalDateTime.now() } diff --git a/core/src/main/kotlin/com/usw/usgo/domain/core/notice/Notice.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/notice/Notice.kt new file mode 100644 index 0000000..a37dcfe --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/notice/Notice.kt @@ -0,0 +1,20 @@ +package com.usw.usgo.domain.core.notice + +import com.usw.usgo.domain.core.BaseEntity +import com.usw.usgo.domain.embeddable.Content +import com.usw.usgo.domain.embeddable.Title +import jakarta.persistence.Embedded +import jakarta.persistence.Entity +import jakarta.persistence.Table + +@Entity +@Table(name = "notice") +class Notice( + + @Embedded + var title: Title, + + @Embedded + var content: Content, +) : BaseEntity() { +} diff --git a/core/src/main/kotlin/com/usw/usgo/domain/core/productpost/ProductPost.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/productpost/ProductPost.kt new file mode 100644 index 0000000..3a79b48 --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/productpost/ProductPost.kt @@ -0,0 +1,40 @@ +package com.usw.usgo.domain.core.productpost + +import com.usw.usgo.domain.core.BaseEntity +import com.usw.usgo.domain.core.user.User +import com.usw.usgo.domain.embeddable.Content +import com.usw.usgo.domain.embeddable.Price +import com.usw.usgo.domain.embeddable.Title +import com.usw.usgo.domain.enumerated.ContactPlace +import jakarta.persistence.* + +@Entity +@Table(name = "product_post") +class ProductPost( + + @Embedded + var title: Title, + + @Embedded + var content: Content, + + @Embedded + var price: Price, + + @Enumerated(EnumType.STRING) + var contactPlace: ContactPlace, + + @Enumerated(EnumType.STRING) + var status: Status = Status.NORMAL, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + val user: User, + + ) : BaseEntity() + +enum class Status { + NORMAL, + RESTRICTED, + DELETED, +} diff --git a/core/src/main/kotlin/com/usw/usgo/domain/user/Cooperation.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/user/Cooperation.kt similarity index 87% rename from core/src/main/kotlin/com/usw/usgo/domain/user/Cooperation.kt rename to core/src/main/kotlin/com/usw/usgo/domain/core/user/Cooperation.kt index d5b1569..fedcaf6 100644 --- a/core/src/main/kotlin/com/usw/usgo/domain/user/Cooperation.kt +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/user/Cooperation.kt @@ -1,4 +1,4 @@ -package com.usw.usgo.domain.user +package com.usw.usgo.domain.core.user import jakarta.persistence.Embeddable import java.time.LocalDateTime diff --git a/core/src/main/kotlin/com/usw/usgo/domain/user/Manner.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/user/Manner.kt similarity index 82% rename from core/src/main/kotlin/com/usw/usgo/domain/user/Manner.kt rename to core/src/main/kotlin/com/usw/usgo/domain/core/user/Manner.kt index b654b39..f704c2f 100644 --- a/core/src/main/kotlin/com/usw/usgo/domain/user/Manner.kt +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/user/Manner.kt @@ -1,4 +1,4 @@ -package com.usw.usgo.domain.user +package com.usw.usgo.domain.core.user import jakarta.persistence.Embeddable import java.math.BigDecimal diff --git a/core/src/main/kotlin/com/usw/usgo/domain/user/User.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/user/User.kt similarity index 60% rename from core/src/main/kotlin/com/usw/usgo/domain/user/User.kt rename to core/src/main/kotlin/com/usw/usgo/domain/core/user/User.kt index ce59dca..9c7dc4d 100644 --- a/core/src/main/kotlin/com/usw/usgo/domain/user/User.kt +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/user/User.kt @@ -1,21 +1,21 @@ -package com.usw.usgo.domain.user +package com.usw.usgo.domain.core.user -import com.usw.usgo.domain.BaseEntity +import com.usw.usgo.domain.core.BaseEntity import jakarta.persistence.* @Entity -@Table(name = "users") +@Table(name = "user") class User( - @Column(length = 50) + @Column(name = "login_id", length = 50, nullable = false) val loginId: String, - @Column(length = 50) + @Column(name = "email", length = 50, nullable = false) val email: String, - @Column(length = 50) + @Column(name = "nickname", length = 50, nullable = false) var nickname: String, - @Column(length = 50) + @Column(name = "password", length = 50, nullable = false) var password: String, @Embedded diff --git a/core/src/main/kotlin/com/usw/usgo/domain/core/userpost/PostLike.kt b/core/src/main/kotlin/com/usw/usgo/domain/core/userpost/PostLike.kt new file mode 100644 index 0000000..ef430e6 --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/core/userpost/PostLike.kt @@ -0,0 +1,20 @@ +package com.usw.usgo.domain.core.userpost + +import com.usw.usgo.domain.core.BaseEntity +import com.usw.usgo.domain.core.productpost.ProductPost +import com.usw.usgo.domain.core.user.User +import jakarta.persistence.* + +@Entity +@Table(name = "post_like") +class PostLike( + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + val user: User, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "product_post_id") + val productPost: ProductPost, + + ) : BaseEntity() diff --git a/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Content.kt b/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Content.kt new file mode 100644 index 0000000..5b5346a --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Content.kt @@ -0,0 +1,11 @@ +package com.usw.usgo.domain.embeddable + +import jakarta.persistence.Column +import jakarta.persistence.Embeddable + +@Embeddable +class Content( + + @Column(nullable = false) + val value: String, +) \ No newline at end of file diff --git a/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Price.kt b/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Price.kt new file mode 100644 index 0000000..62aadc8 --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Price.kt @@ -0,0 +1,11 @@ +package com.usw.usgo.domain.embeddable + +import jakarta.persistence.Column +import jakarta.persistence.Embeddable + +@Embeddable +class Price( + + @Column(nullable = false) + val value: Int, +) \ No newline at end of file diff --git a/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Title.kt b/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Title.kt new file mode 100644 index 0000000..a5f633f --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/embeddable/Title.kt @@ -0,0 +1,11 @@ +package com.usw.usgo.domain.embeddable + +import jakarta.persistence.Column +import jakarta.persistence.Embeddable + +@Embeddable +class Title( + + @Column(nullable = false) + val value: String, +) \ No newline at end of file diff --git a/core/src/main/kotlin/com/usw/usgo/domain/enumerated/ContactPlace.kt b/core/src/main/kotlin/com/usw/usgo/domain/enumerated/ContactPlace.kt new file mode 100644 index 0000000..7ec6966 --- /dev/null +++ b/core/src/main/kotlin/com/usw/usgo/domain/enumerated/ContactPlace.kt @@ -0,0 +1,6 @@ +package com.usw.usgo.domain.enumerated + +enum class ContactPlace { + + IT, ACE, GLOBAL, +} \ No newline at end of file diff --git a/core/src/main/kotlin/com/usw/usgo/domain/notice/Notice.kt b/core/src/main/kotlin/com/usw/usgo/domain/notice/Notice.kt deleted file mode 100644 index 1620c9a..0000000 --- a/core/src/main/kotlin/com/usw/usgo/domain/notice/Notice.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.usw.usgo.domain.notice - -import com.usw.usgo.domain.BaseEntity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Table - -@Entity -@Table(name = "notices") -class Notice( - @Column(length = 50) - var title: String, - - @Column(columnDefinition = "text") - var content: String, -) : BaseEntity() { -} diff --git a/core/src/main/kotlin/com/usw/usgo/domain/productpost/PostLike.kt b/core/src/main/kotlin/com/usw/usgo/domain/productpost/PostLike.kt deleted file mode 100644 index 1665aff..0000000 --- a/core/src/main/kotlin/com/usw/usgo/domain/productpost/PostLike.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.usw.usgo.domain.productpost - -import com.usw.usgo.domain.BaseEntity -import jakarta.persistence.Entity -import jakarta.persistence.Table - -@Entity -@Table(name = "post_likes") -class PostLike( - val userId: Int, - val postId: Int, - var isDeleted: Boolean -) : BaseEntity() { -} diff --git a/core/src/main/kotlin/com/usw/usgo/domain/productpost/ProductPost.kt b/core/src/main/kotlin/com/usw/usgo/domain/productpost/ProductPost.kt deleted file mode 100644 index 1f13a2f..0000000 --- a/core/src/main/kotlin/com/usw/usgo/domain/productpost/ProductPost.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.usw.usgo.domain.productpost - -import com.usw.usgo.domain.BaseEntity -import jakarta.persistence.* - -@Entity -@Table(name = "product_posts") -class ProductPost( - val userId: Long, - - @Column(length = 50) - var title: String, - - @Column(columnDefinition = "text") - var content: String, - - @Column(length = 50) - var contactPlace: String, - - var price: Int, - - @Enumerated(EnumType.STRING) - var status: Status = Status.NORMAL, - ) : BaseEntity() { -} - -enum class Status { - NORMAL, - RESTRICTED, - DELETED, -}