Skip to content

Commit

Permalink
#496 [fix] QA 사항 반영
Browse files Browse the repository at this point in the history
#496 [fix] QA 사항 반영
  • Loading branch information
sohyundoh authored Aug 17, 2024
2 parents 0c19a44 + 1046319 commit 8ecc1fc
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public record PostListResponse(
) {
private static final int SUBSTRING_START = 0;
private static final int SUBSTRING_END = 400;

private static final String UNNAMED = "작자미상";
public static PostListResponse of(final Post post, final int commentCount) {

return new PostListResponse(post.getIdUrl(), post.getTitle(), getSubString(post),
post.getWriterName().getName(),
getWriterName(post),
DateUtil.getStringWithTimeOfLocalDate(post.getCreatedAt()),
post.getCuriousCount(),
post.getHitsCount(),
Expand All @@ -31,6 +32,11 @@ public static PostListResponse of(final Post post, final int commentCount) {
post.isContainPhoto());
}

private static String getWriterName(final Post post) {
if(post.isAnonymous()) return UNNAMED;
else return post.getWriterName().getName();
}

private static String getSubString(final Post post) {
String cleanContent = Jsoup.clean(post.getContent(), Safelist.none());
if (cleanContent.length() >= SUBSTRING_END) {
Expand Down

0 comments on commit 8ecc1fc

Please sign in to comment.