From a8023d5f4067f4c8ad708c4a4302e6f8021628ed Mon Sep 17 00:00:00 2001 From: kang Date: Sun, 17 Mar 2024 17:14:26 +0900 Subject: [PATCH 1/2] feat: add previous in PageInfo dto --- src/main/java/floud/demo/dto/PageInfo.java | 1 + .../java/floud/demo/service/CommunityService.java | 11 ++++++----- .../java/floud/demo/service/FriendshipService.java | 11 ++++++----- src/main/java/floud/demo/service/MyPageService.java | 3 ++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/floud/demo/dto/PageInfo.java b/src/main/java/floud/demo/dto/PageInfo.java index 6ce067f..b6f6d42 100644 --- a/src/main/java/floud/demo/dto/PageInfo.java +++ b/src/main/java/floud/demo/dto/PageInfo.java @@ -10,4 +10,5 @@ public class PageInfo { private Integer totalPages; private Long totalElements; private Boolean last; + private Boolean previous; } diff --git a/src/main/java/floud/demo/service/CommunityService.java b/src/main/java/floud/demo/service/CommunityService.java index 8144f53..d3e7f2d 100644 --- a/src/main/java/floud/demo/service/CommunityService.java +++ b/src/main/java/floud/demo/service/CommunityService.java @@ -126,12 +126,13 @@ private List setPostList(Page communityPage){ .toList(); } - private PageInfo setPageInfo(Page postPage){ + private PageInfo setPageInfo(Page communityPage){ return PageInfo.builder() - .last(!postPage.hasNext()) - .nowPage(postPage.getNumber()) - .totalPages(postPage.getTotalPages()) - .totalElements(postPage.getTotalElements()) + .last(!communityPage.hasNext()) + .previous(communityPage.hasPrevious()) + .nowPage(communityPage.getNumber()) + .totalPages(communityPage.getTotalPages()) + .totalElements(communityPage.getTotalElements()) .build(); } diff --git a/src/main/java/floud/demo/service/FriendshipService.java b/src/main/java/floud/demo/service/FriendshipService.java index 9cbd021..cb131ef 100644 --- a/src/main/java/floud/demo/service/FriendshipService.java +++ b/src/main/java/floud/demo/service/FriendshipService.java @@ -216,12 +216,13 @@ public List findFriendInfo(Users me, LocalDate date, Page postPage){ + private PageInfo setPageInfo(Page friendshipPage){ return PageInfo.builder() - .last(!postPage.hasNext()) - .nowPage(postPage.getNumber()) - .totalPages(postPage.getTotalPages()) - .totalElements(postPage.getTotalElements()) + .last(!friendshipPage.hasNext()) + .previous(friendshipPage.hasPrevious()) + .nowPage(friendshipPage.getNumber()) + .totalPages(friendshipPage.getTotalPages()) + .totalElements(friendshipPage.getTotalElements()) .build(); } } diff --git a/src/main/java/floud/demo/service/MyPageService.java b/src/main/java/floud/demo/service/MyPageService.java index 88e857c..4f7fae4 100644 --- a/src/main/java/floud/demo/service/MyPageService.java +++ b/src/main/java/floud/demo/service/MyPageService.java @@ -219,7 +219,8 @@ private Users getFriend(Friendship friendship, Users me) { private PageInfo setPageInfo(Page postPage){ return PageInfo.builder() .last(!postPage.hasNext()) - .nowPage(postPage.getNumber()) + .previous(postPage.hasPrevious()) + .nowPage(postPage.getNumber()+1) .totalPages(postPage.getTotalPages()) .totalElements(postPage.getTotalElements()) .build(); From c6f7c4067f5f703d255e125fc667a7336f03a8db Mon Sep 17 00:00:00 2001 From: kang Date: Sun, 17 Mar 2024 17:15:14 +0900 Subject: [PATCH 2/2] chore: change position --- src/main/java/floud/demo/dto/PageInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/floud/demo/dto/PageInfo.java b/src/main/java/floud/demo/dto/PageInfo.java index b6f6d42..8ca9ec7 100644 --- a/src/main/java/floud/demo/dto/PageInfo.java +++ b/src/main/java/floud/demo/dto/PageInfo.java @@ -9,6 +9,6 @@ public class PageInfo { private Integer nowPage; private Integer totalPages; private Long totalElements; - private Boolean last; private Boolean previous; + private Boolean last; }