Skip to content

Commit

Permalink
🐛 [Fix] 방식 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
coldmans committed Jan 19, 2025
1 parent 4db4431 commit 617f133
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public ApiResponse<String> delete(@PathVariable Long boardId, @AuthMember Member
@GetMapping("/my")
@Operation(summary = "내가 작성한 게시판 글 목록 조회 API", description = "내가 작성한 게시판 글을 조회하는 API 입니다. 페이지 당 10개의 게시물이 표시됩니다.")
@Parameter(name = "pageIdx", description = "조회할 페이지 번호를 입력해주세요.")
public ApiResponse<MyBoardResponse> getMyBoardList(@RequestParam(defaultValue = "1") int pageIdx,
public ApiResponse<MyBoardResponse> getMyBoardList(@ValidPage @RequestParam(name = "page") Integer page,
@AuthMember Member member) {
return ApiResponse.ok(boardFacadeService.getMyBoardList(member, pageIdx));
return ApiResponse.ok(boardFacadeService.getMyBoardList(member, page));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void deleteBoard(Member member, Long boardId) {
* 내가 작성한 게시글 목록 조회 (파사드)
*/
public MyBoardResponse getMyBoardList(Member member, int pageIdx) {
Page<Board> boardPage = boardService.getMyBoards(member.getId(), pageIdx, 10);
Page<Board> boardPage = boardService.getMyBoards(member.getId(), pageIdx);
return MyBoardResponse.of(boardPage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class BoardService {

private final BoardRepository boardRepository;
public static final int PAGE_SIZE = 20;
public static final int MY_PAGE_SIZE = 10;

/**
* 게시글 엔티티 생성 및 저장
Expand Down Expand Up @@ -115,12 +116,12 @@ public void deleteBoard(Long boardId, Long memberId) {
/**
* 내가 작성한 게시글(Page) 조회
*/
public Page<Board> getMyBoards(Long memberId, int pageIdx, int pageSize) {
public Page<Board> getMyBoards(Long memberId, int pageIdx) {
if (pageIdx <= 0) {
throw new IllegalArgumentException("pageIdx는 1 이상의 값이어야 합니다.");
}
// PageRequest.of의 첫 번째 인자(pageIdx - 1)는 0-based index
Pageable pageable = PageRequest.of(pageIdx - 1, pageSize, Sort.by(Sort.Direction.DESC, "createdAt"));
Pageable pageable = PageRequest.of(pageIdx - 1, MY_PAGE_SIZE, Sort.by(Sort.Direction.DESC, "createdAt"));
return boardRepository.findByMemberIdAndDeletedFalse(memberId, pageable);
}

Expand Down

0 comments on commit 617f133

Please sign in to comment.