Skip to content

Commit

Permalink
feat: 뉴스레터 좋아요 엔티티 추가 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
why-only-english committed Feb 14, 2024
1 parent b190416 commit d812029
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit d812029

Please sign in to comment.