Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix/4-getMyPage5] 마이페이지 목록 내용 글자수 수정 #42

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ public class GetCommentResponse {
private String postTitle;

//TODO : DTO 변환 메소드 위치 변경
//TODO : dto에서 LocalDateTime -> LocalDate로 변경
public static GetCommentResponse fromComment(Comment comment) {
Post post = comment.getPost();

String title;
if(post.getTitle().length() > 10) title = post.getTitle().substring(0, 10) + "...";
if(post.getTitle().length() > 23) title = post.getTitle().substring(0, 23) + "...";
else title = post.getTitle();

String content;
if(comment.getContent().length() > 20) content = comment.getContent().substring(0, 20) + "...";
if(comment.getContent().length() > 25) content = comment.getContent().substring(0, 25) + "...";
else content = comment.getContent();

return GetCommentResponse.builder().content(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public static GetJunyQuestionResponse fromPost(Post post, Long answerCount, Bool
LocalDate targetDate = post.getCreatedDate().toLocalDate().plusDays(3);
LocalDateTime date = (isJuicy)? post.getLastModifiedDate() : post.getCreatedDate();
String title;
if(post.getTitle().length() > 20)
title = post.getTitle().substring(0, 20) + "...";
if(post.getTitle().length() > 22)
title = post.getTitle().substring(0, 22) + "...";
else title = post.getTitle();
return GetJunyQuestionResponse.builder()
.title(title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ public class GetScrapResponse {
public static GetScrapResponse fromScrap(Scrap scrap) {
Post post = scrap.getPost();
String title;
if(post.getTitle().length() > 10) title = post.getTitle().substring(0, 10) + "...";
if(post.getTitle().length() > 21) title = post.getTitle().substring(0, 21) + "...";
else title = post.getTitle();

String content;
if(post.getContent().length() > 45) content = post.getContent().substring(0, 45) + "...";
if(post.getContent().length() > 58)
content = post.getContent().substring(0, 30) + "\n" + post.getContent().substring(30, 58) + "...";
else if(post.getContent().length() > 30)
content = post.getContent().substring(0, 30) + "\n" + post.getContent().substring(30);
else content = post.getContent();

return GetScrapResponse.builder().postTitle(title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static GetSinyAnswerResponse fromAnswer(Answer answer, Long answerCount,
LocalDateTime date = (isJuicy)? answer.getPost().getLastModifiedDate() : answer.getPost().getCreatedDate();

String content;
if(answer.getContent().length() > 20) content = answer.getContent().substring(0, 20) + "...";
if(answer.getContent().length() > 22) content = answer.getContent().substring(0, 22) + "...";
else content = answer.getContent();

return GetSinyAnswerResponse.builder()
Expand Down