-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b190416
commit d812029
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/com/api/ttoklip/domain/newsletter/like/entity/NewsletterLike.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |