Skip to content

Commit

Permalink
Merge pull request #57 from lotteon2/develop
Browse files Browse the repository at this point in the history
[FIX] fix post sorting
  • Loading branch information
CokeLee777 authored Jan 18, 2024
2 parents e6fc5fc + 3a3fcaf commit 571a7ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/dailyon/snsservice/entity/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,12 @@ public void addCommentCount(Integer count) {
public void setDeleted(Boolean deleted) {
this.isDeleted = deleted;
}

public void setViewCount(Integer viewCount) {
this.viewCount = viewCount;
}

public void setLikeCount(Integer likeCount) {
this.likeCount = likeCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ public PostLikePageResponse getPostLikes(Long memberId, Pageable pageable) {

List<Post> modifiedPosts = new ArrayList<>();

PostLikePageResponse postLikePageResponse = PostLikePageResponse.fromEntity(posts);
postLikePageResponse
.getPosts()
posts
.forEach(
post -> {
try {
Expand All @@ -189,6 +187,8 @@ public PostLikePageResponse getPostLikes(Long memberId, Pageable pageable) {
// cache count 값으로 response를 업데이트
post.setViewCount(cachedPostCountVO.getViewCount());
post.setLikeCount(cachedPostCountVO.getLikeCount());

modifiedPosts.add(post);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -237,6 +237,9 @@ public OOTDPostPageResponse getMyOOTDPosts(Long memberId, Pageable pageable) {
// cache count 값으로 response를 업데이트
OOTDPostResponse.setViewCount(cachedPostCountVO.getViewCount());
OOTDPostResponse.setLikeCount(cachedPostCountVO.getLikeCount());

// Add the modified PostResponse to the list
modifiedMyOOTDPostResponses.add(OOTDPostResponse);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -286,6 +289,9 @@ public OOTDPostPageResponse getMemberOOTDPosts(
// cache count 값으로 response를 업데이트
OOTDPostResponse.setViewCount(cachedPostCountVO.getViewCount());
OOTDPostResponse.setLikeCount(cachedPostCountVO.getLikeCount());

// Add the modified PostResponse to the list
modifiedMemberOOTDPostResponses.add(OOTDPostResponse);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 571a7ac

Please sign in to comment.