Skip to content

Commit

Permalink
feat : 3차 세미나 실습 과제_post 생성 정적 메서드 추가 #7
Browse files Browse the repository at this point in the history
  • Loading branch information
PicturePark1101 committed May 1, 2024
1 parent 691643a commit 0978fe5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.demo.domain;

import com.example.demo.service.dto.blog.BlogCreateRequest;
import com.example.demo.service.dto.post.PostCreateRequest;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand All @@ -24,4 +26,15 @@ public class Post extends BaseTimeEntity {

@ManyToOne(fetch = FetchType.LAZY)
private Blog blog;


private Post(Blog blog, String name, String content) {
this.blog = blog;
this.name = name;
this.content = content;
}

public static Post create(Blog blog, PostCreateRequest postCreateRequest) {
return new Post(blog, postCreateRequest.name(), postCreateRequest.content());
}
}

0 comments on commit 0978fe5

Please sign in to comment.