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 fd93d2c commit 7249175
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.api.ttoklip.domain.newsletter.scarp.entity;

import com.api.ttoklip.domain.common.base.BaseTimeEntity;
import com.api.ttoklip.domain.member.domain.Member;
import com.api.ttoklip.domain.newsletter.post.domain.Newsletter;
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 NewsletterScrap extends BaseTimeEntity {

@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 NewsletterScrap from(final Newsletter newsletter) {
return NewsletterScrap.builder()
.member(getCurrentMember())
.newsletter(newsletter)
.build();
}
}

0 comments on commit 7249175

Please sign in to comment.