Skip to content

Commit

Permalink
refactor: (#284) 불필요한 메서드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
jeomxon committed Aug 7, 2023
1 parent 67b3d77 commit 096952b
Showing 1 changed file with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,6 @@ public record PostDetailResponse(
VoteDetailResponse voteInfo
) {

public static PostDetailResponse from(final Post post) {
final Member writer = post.getWriter();
final PostBody postBody = post.getPostBody();
final List<PostContentImage> contentImages = postBody.getPostContentImages().getContentImages();
final StringBuilder contentImageUrl = new StringBuilder();

if (!contentImages.isEmpty()) {
contentImageUrl.append(contentImages.get(0).getImageUrl());
}

final PostCategories postCategories = post.getPostCategories();
return new PostDetailResponse(
post.getId(),
WriterResponse.of(writer.getId(), writer.getNickname()),
postBody.getTitle(),
postBody.getContent(),
convertImageUrl(contentImageUrl.toString()),
getCategories(postCategories.getPostCategories()),
post.getCreatedAt(),
post.getDeadline(),
VoteDetailResponse.of(
0,
-1,
getOptionsByGuest(post)
)
);
}

public static PostDetailResponse of(final Post post, final Member loginMember) {
final Member writer = post.getWriter();
final PostBody postBody = post.getPostBody();
Expand Down Expand Up @@ -108,16 +80,4 @@ private static List<PostOptionDetailResponse> getOptions(
.toList();
}

private static List<PostOptionDetailResponse> getOptionsByGuest(final Post post) {
return post.getPostOptions().getPostOptions().stream()
.map(postOption ->
PostOptionDetailResponse.of(
postOption,
false,
-1L
)
)
.toList();
}

}

0 comments on commit 096952b

Please sign in to comment.