Skip to content

Commit

Permalink
fix: paging_number 시작 idx 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nahyeon99 committed Aug 3, 2024
1 parent a1834e7 commit 729fd7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.xml.parsers.ParserConfigurationException;

import org.apache.poi.ooxml.util.SAXHelper;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public Question getById(Long id) {
.orElseThrow(NotFoundQuestionException::new);
}

public QuestionListResponse findQuestions(Long userId, Long meetingId, int page, int size) {
public QuestionListResponse findQuestions(Long userId, Long meetingId, PageRequest pageRequest) {
MeetingMember loginMember = meetingMemberService.getByUserIdAndMeetingId(userId, meetingId);
Meeting meeting = loginMember.getMeeting();
return questionRepository.findQuestionsByMeeting(meeting.getId(), PageRequest.of(page, size));
return questionRepository.findQuestionsByMeeting(meeting.getId(), pageRequest);
}

public QuestionResponse getRandomOne(List<Long> excludeQuestionIds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ public QuestionListResponse findQuestionsByMeeting(Long meetingId, Pageable page
List<Long> usedQuestionIds = queryFactory
.select(meetingQuestion.question.id)
.from(meetingQuestion)
.where(meetingIdEq(meetingId))
.orderBy(meetingQuestion.question.createdAt.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.where(meetingQuestion.meeting.id.eq(meetingId))
.fetch();

List<QuestionSummaryResponse> questionSummaryResponses = queryFactory
Expand All @@ -58,6 +55,8 @@ public QuestionListResponse findQuestionsByMeeting(Long meetingId, Pageable page
.from(question)
.where(question.id.notIn(usedQuestionIds))
.orderBy(question.createdAt.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();

List<Long> totalElementIds = queryFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.depromeet.sambad.moring.question.presentation.response.QuestionListResponse;
import org.depromeet.sambad.moring.question.presentation.response.QuestionResponse;
import org.depromeet.sambad.moring.user.presentation.resolver.UserId;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -60,7 +61,7 @@ public ResponseEntity<QuestionListResponse> findQuestions(
@Parameter(description = "페이지 인덱스, 요청 값이 없으면 0으로 설정", example = "0") @RequestParam(value = "page", defaultValue = "0") int page,
@Parameter(description = "응답 개수, 요청 값이 없으면 10으로 설정", example = "10") @RequestParam(value = "size", defaultValue = "10") int size
) {
QuestionListResponse response = questionService.findQuestions(userId, meetingId, page, size);
QuestionListResponse response = questionService.findQuestions(userId, meetingId, PageRequest.of(page, size));
return ResponseEntity.ok(response);
}

Expand Down

0 comments on commit 729fd7f

Please sign in to comment.