Skip to content

Commit

Permalink
#4 feat: PostDto 컨버터 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Sehee-Lee-01 committed Nov 16, 2023
1 parent 3482633 commit 50f6f71
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/example/board/model/Post.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.board.model;

import com.example.board.dto.PostDto;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
Expand All @@ -24,4 +25,18 @@ public class Post extends BaseEntity {

@Lob
private String contents;

@Column(name = "created_by")
private String createdBy;

private Post(User user, PostDto postDto) {
this.user = user;
this.title = postDto.title();
this.contents = postDto.contents();
this.createdBy = user.getName();
}

public static Post from(User user, PostDto postDto) {
return new Post(user, postDto);
}
}

0 comments on commit 50f6f71

Please sign in to comment.