diff --git a/src/main/java/kr/tgwing/tech/blog/dto/PostDetail.java b/src/main/java/kr/tgwing/tech/blog/dto/PostDetail.java index a43f557..3c53fe9 100644 --- a/src/main/java/kr/tgwing/tech/blog/dto/PostDetail.java +++ b/src/main/java/kr/tgwing/tech/blog/dto/PostDetail.java @@ -1,5 +1,6 @@ package kr.tgwing.tech.blog.dto; +import java.time.format.DateTimeFormatter; import java.util.Set; import lombok.Builder; @@ -18,16 +19,19 @@ public class PostDetail { private String title; private String content; private String thumbnail; + private String modDate; private int likeCount; private int commnetCount; @Singular private Set hashtags; public static PostDetail of(Post post) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); var builder = PostDetail.builder() .id(post.getId()) .title(post.getTitle()) .writer(ProfileDTO.of(post.getWriter())) .thumbnail(post.getThumbnail()) + .modDate(post.getModDate().format(formatter)) .content(post.getContent()) .commnetCount(post.getComments().size()); diff --git a/src/main/java/kr/tgwing/tech/blog/dto/PostOverview.java b/src/main/java/kr/tgwing/tech/blog/dto/PostOverview.java index e13992b..c20f305 100644 --- a/src/main/java/kr/tgwing/tech/blog/dto/PostOverview.java +++ b/src/main/java/kr/tgwing/tech/blog/dto/PostOverview.java @@ -1,5 +1,6 @@ package kr.tgwing.tech.blog.dto; +import java.time.format.DateTimeFormatter; import java.util.Set; import lombok.Builder; @@ -19,17 +20,22 @@ public class PostOverview { private ProfileDTO writer; private String title; private String summary; + private String thumbnail; + private String modDate; private int likeCount; private int commentCount; @Singular private final Set hashtags; public static PostOverview of(Post post) { String content = post.getContent(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); return PostOverview.builder() .id(post.getId()) .writer(ProfileDTO.of(post.getWriter())) .title(post.getTitle()) .summary((content.length() < SUMMARY_LENGTH) ? content : content.substring(0, SUMMARY_LENGTH)) + .thumbnail(post.getThumbnail()) + .modDate(post.getModDate().format(formatter)) .commentCount(post.getComments().size()) .hashtags(post.getHashtags().stream().map(hashtag -> hashtag.getName()).toList()) .build();