From d812029634ea24792eb61239f8aad4ed43773d8e Mon Sep 17 00:00:00 2001 From: jgmoon <6813821@tukorea.ac.kr> Date: Thu, 15 Feb 2024 00:57:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=89=B4=EC=8A=A4=EB=A0=88=ED=84=B0=20?= =?UTF-8?q?=EC=A2=8B=EC=95=84=EC=9A=94=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#63)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../like/entity/NewsletterLike.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/api/ttoklip/domain/newsletter/like/entity/NewsletterLike.java diff --git a/src/main/java/com/api/ttoklip/domain/newsletter/like/entity/NewsletterLike.java b/src/main/java/com/api/ttoklip/domain/newsletter/like/entity/NewsletterLike.java new file mode 100644 index 00000000..e280ef0f --- /dev/null +++ b/src/main/java/com/api/ttoklip/domain/newsletter/like/entity/NewsletterLike.java @@ -0,0 +1,38 @@ +package com.api.ttoklip.domain.newsletter.like.entity; + +import com.api.ttoklip.domain.member.domain.Member; +import com.api.ttoklip.domain.newsletter.post.domain.Newsletter; +import com.fasterxml.jackson.databind.ser.Serializers; +import jakarta.persistence.*; +import lombok.*; + +import static com.api.ttoklip.global.util.SecurityUtil.getCurrentMember; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class NewsletterLike extends Serializers.Base { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", updatable = false) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + private Member member; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "newsletter_id") + private Newsletter newsletter; + + public static NewsletterLike from(final Newsletter newsletter) { + return NewsletterLike.builder() + .member(getCurrentMember()) + .newsletter(newsletter) + .build(); + } + +}