Skip to content

Commit

Permalink
[fix] : 페이징 이슈 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
evergreenn committed Apr 7, 2024
1 parent 36c7979 commit 81d9f2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.cona.KUsukKusuk.user.dto.BoomarkLikeResponseDto;
import com.cona.KUsukKusuk.user.dto.PageInfo;
import com.cona.KUsukKusuk.user.service.UserService;
import java.util.Collections;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -116,8 +117,8 @@ public List<CommentListResponseDto> getPagedComments( int
int start = Math.min(pageNumber * pageSize, comments.size());
int end = Math.min((pageNumber + 1) * pageSize, comments.size());

if (start > end) {
start = end;
if (start >= comments.size()) {
return Collections.emptyList(); // 페이지 범위를 벗어나면 빈 리스트 반환
}
PageInfo pageInfo = new PageInfo();
pageInfo.setTotalElements(comments.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import jakarta.transaction.Transactional;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -290,8 +291,8 @@ public List<BoomarkLikeResponseDto> getBookmarkandLikes(int pageNumber, int page
int start = Math.min(pageNumber * pageSize, distinctSpots.size());
int end = Math.min((pageNumber + 1) * pageSize, distinctSpots.size());

if (start > end) {
start = end;
if (start >= distinctSpots.size()) {
return Collections.emptyList();
}
PageInfo pageInfo = new PageInfo();
pageInfo.setTotalElements(distinctSpots.size());
Expand Down

0 comments on commit 81d9f2d

Please sign in to comment.