Skip to content

Commit

Permalink
#199 Refactor: 인기글, 최신글, 팔로잉글 조회시 postImageUrl 리스트도 함께 반환하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkJh38 committed Aug 20, 2024
1 parent 111921b commit bab5a34
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 30 deletions.
110 changes: 90 additions & 20 deletions src/main/java/com/codiary/backend/global/converter/PostConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,30 @@ public static List<PostResponseDTO.CommentDTO> toCommentListDTO(List<Comment> co

// 메인페이지 인기글 전체 리스트 조회
public static PostResponseDTO.PostPopularDTO toPostPopularDTO(Post post) {
List<String> postCategories = post.getCategoriesList().stream()
.map(Categories::getName)
.collect(Collectors.toList());

return PostResponseDTO.PostPopularDTO.builder()
.postId(post.getPostId())
.memberId(post.getMember().getMemberId())
.fileUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postTitle(post.getPostTitle())
.nickname(post.getMember().getNickname())
.teamId(post.getTeam() != null ? post.getTeam().getTeamId() : null)
.projectId(post.getProject() != null ? post.getProject().getProjectId() : null)
.postTitle(post.getPostTitle())
.postBody(post.getPostBody())
.postStatus(post.getPostStatus())
.postCategory(String.join(", ", postCategories))
.coauthorIds(post.getAuthorsList().stream()
.map(author -> author.getMember().getMemberId())
.collect(Collectors.toSet()))
.postAccess(post.getPostAccess())
.thumbnailImageUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postFileList(PostFileConverter.toPostFileListDTO(post.getPostFileList()))
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.build();
}

Expand All @@ -495,16 +509,30 @@ public static PostResponseDTO.PostPopularListDTO toPostPopularListDTO(Page<Post>

// 메인페이지 인기글 멤버 관심 카테고리별 리스트 조회
public static PostResponseDTO.PostPopularMemberCategoryDTO toPostPopularMemberCategoryDTO(Post post) {
List<String> postCategories = post.getCategoriesList().stream()
.map(Categories::getName)
.collect(Collectors.toList());

return PostResponseDTO.PostPopularMemberCategoryDTO.builder()
.postId(post.getPostId())
.memberId(post.getMember().getMemberId())
.fileUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postTitle(post.getPostTitle())
.nickname(post.getMember().getNickname())
.teamId(post.getTeam() != null ? post.getTeam().getTeamId() : null)
.projectId(post.getProject() != null ? post.getProject().getProjectId() : null)
.postTitle(post.getPostTitle())
.postBody(post.getPostBody())
.postStatus(post.getPostStatus())
.postCategory(String.join(", ", postCategories))
.coauthorIds(post.getAuthorsList().stream()
.map(author -> author.getMember().getMemberId())
.collect(Collectors.toSet()))
.postAccess(post.getPostAccess())
.thumbnailImageUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postFileList(PostFileConverter.toPostFileListDTO(post.getPostFileList()))
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.build();
}

Expand All @@ -524,16 +552,30 @@ public static PostResponseDTO.PostPopularMemberCategoryListDTO toPostPopularMemb

// 메인페이지 최신글 리스트 조회
public static PostResponseDTO.PostLatestDTO toPostLatestDTO(Post post) {
List<String> postCategories = post.getCategoriesList().stream()
.map(Categories::getName)
.collect(Collectors.toList());

return PostResponseDTO.PostLatestDTO.builder()
.postId(post.getPostId())
.memberId(post.getMember().getMemberId())
.fileUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postTitle(post.getPostTitle())
.nickname(post.getMember().getNickname())
.teamId(post.getTeam() != null ? post.getTeam().getTeamId() : null)
.projectId(post.getProject() != null ? post.getProject().getProjectId() : null)
.postTitle(post.getPostTitle())
.postBody(post.getPostBody())
.postStatus(post.getPostStatus())
.postCategory(String.join(", ", postCategories))
.coauthorIds(post.getAuthorsList().stream()
.map(author -> author.getMember().getMemberId())
.collect(Collectors.toSet()))
.postAccess(post.getPostAccess())
.thumbnailImageUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postFileList(PostFileConverter.toPostFileListDTO(post.getPostFileList()))
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.build();
}

Expand All @@ -553,16 +595,30 @@ public static PostResponseDTO.PostLatestListDTO toPostLatestListDTO(Page<Post> p

// 메인페이지 팔로잉 게시글 리스트 조회
public static PostResponseDTO.PostFollowingDTO toPostFollowingDTO(Post post) {
List<String> postCategories = post.getCategoriesList().stream()
.map(Categories::getName)
.collect(Collectors.toList());

return PostResponseDTO.PostFollowingDTO.builder()
.postId(post.getPostId())
.memberId(post.getMember().getMemberId())
.fileUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postTitle(post.getPostTitle())
.nickname(post.getMember().getNickname())
.teamId(post.getTeam() != null ? post.getTeam().getTeamId() : null)
.projectId(post.getProject() != null ? post.getProject().getProjectId() : null)
.postTitle(post.getPostTitle())
.postBody(post.getPostBody())
.postStatus(post.getPostStatus())
.postCategory(String.join(", ", postCategories))
.coauthorIds(post.getAuthorsList().stream()
.map(author -> author.getMember().getMemberId())
.collect(Collectors.toSet()))
.postAccess(post.getPostAccess())
.thumbnailImageUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postFileList(PostFileConverter.toPostFileListDTO(post.getPostFileList()))
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.build();
}

Expand All @@ -582,16 +638,30 @@ public static PostResponseDTO.PostFollowingListDTO toPostFollowingListDTO(Page<P

// 제목 & 본문 & 저자 & 프로젝트 & 카테고리 검색
public static PostResponseDTO.PostSearchTitleDTO toPostSearchTitleDTO(Post post) {
List<String> postCategories = post.getCategoriesList().stream()
.map(Categories::getName)
.collect(Collectors.toList());

return PostResponseDTO.PostSearchTitleDTO.builder()
.postId(post.getPostId())
.memberId(post.getMember().getMemberId())
.fileUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postTitle(post.getPostTitle())
.nickname(post.getMember().getNickname())
.teamId(post.getTeam() != null ? post.getTeam().getTeamId() : null)
.projectId(post.getProject() != null ? post.getProject().getProjectId() : null)
.postTitle(post.getPostTitle())
.postBody(post.getPostBody())
.postStatus(post.getPostStatus())
.postCategory(String.join(", ", postCategories))
.coauthorIds(post.getAuthorsList().stream()
.map(author -> author.getMember().getMemberId())
.collect(Collectors.toSet()))
.postAccess(post.getPostAccess())
.thumbnailImageUrl((post.getThumbnailImage() != null)
? post.getThumbnailImage().getFileUrl()
: "")
.postFileList(PostFileConverter.toPostFileListDTO(post.getPostFileList()))
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,19 @@ public static class PostPopularListDTO {
public static class PostPopularDTO {
Long postId;
Long memberId;
String fileUrl;
String postTitle;
String nickname;
Long teamId;
Long projectId;
String postTitle;
String postBody;
String thumbnailImageUrl;
Boolean postStatus;
String postCategory;
Set<Long> coauthorIds;
PostAccess postAccess;
PostFileResponseDTO.PostFileListDTO postFileList;
LocalDateTime createdAt;
LocalDateTime updatedAt;
}

// 메인페이지 인기글 멤버 관심 카테고리별 리스트 조회
Expand All @@ -407,11 +415,19 @@ public static class PostPopularMemberCategoryListDTO {
public static class PostPopularMemberCategoryDTO {
Long postId;
Long memberId;
String fileUrl;
String postTitle;
String nickname;
Long teamId;
Long projectId;
String postTitle;
String postBody;
String thumbnailImageUrl;
Boolean postStatus;
String postCategory;
Set<Long> coauthorIds;
PostAccess postAccess;
PostFileResponseDTO.PostFileListDTO postFileList;
LocalDateTime createdAt;
LocalDateTime updatedAt;
}

// 메인페이지 최신글 리스트 조회
Expand All @@ -435,11 +451,19 @@ public static class PostLatestListDTO {
public static class PostLatestDTO {
Long postId;
Long memberId;
String fileUrl;
String postTitle;
String nickname;
Long teamId;
Long projectId;
String postTitle;
String postBody;
String thumbnailImageUrl;
Boolean postStatus;
String postCategory;
Set<Long> coauthorIds;
PostAccess postAccess;
PostFileResponseDTO.PostFileListDTO postFileList;
LocalDateTime createdAt;
LocalDateTime updatedAt;
}

// 메인페이지 팔로잉 게시글 리스트 조회
Expand All @@ -463,11 +487,19 @@ public static class PostFollowingListDTO {
public static class PostFollowingDTO {
Long postId;
Long memberId;
String fileUrl;
String postTitle;
String nickname;
Long teamId;
Long projectId;
String postTitle;
String postBody;
String thumbnailImageUrl;
Boolean postStatus;
String postCategory;
Set<Long> coauthorIds;
PostAccess postAccess;
PostFileResponseDTO.PostFileListDTO postFileList;
LocalDateTime createdAt;
LocalDateTime updatedAt;
}

// 제목 & 본문 & 저자 & 프로젝트 & 카테고리 검색
Expand All @@ -491,11 +523,19 @@ public static class PostSearchTitleListDTO {
public static class PostSearchTitleDTO {
Long postId;
Long memberId;
String fileUrl;
String postTitle;
String nickname;
Long teamId;
Long projectId;
String postTitle;
String postBody;
String thumbnailImageUrl;
Boolean postStatus;
String postCategory;
Set<Long> coauthorIds;
PostAccess postAccess;
PostFileResponseDTO.PostFileListDTO postFileList;
LocalDateTime createdAt;
LocalDateTime updatedAt;
}

}
Expand Down

0 comments on commit bab5a34

Please sign in to comment.