Skip to content

Commit

Permalink
등록된 모든 게시글 수 api 추가 #84 DAILYLIFE2-25
Browse files Browse the repository at this point in the history
  • Loading branch information
ykp9711 committed Aug 9, 2022
1 parent b73b515 commit 475cf4b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ public ResponseEntity<List<BoardCreateAndGetResponse>> list(@PathVariable("pg")i
return ResponseEntity.ok(boardService.getPage(pagination));
}

@ApiOperation(value = "전체 게시글 수 가져오기", notes = "등록된 게시물 수 가져오기")
@GetMapping("/getBoardCount")
public ResponseEntity<Integer> getBoardCount() {
return ResponseEntity.ok(boardService.getBoardCount());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
public interface BoardRepository extends JpaRepository<Board, Long> {
Board findBoardByBoardNum(Long boardNum);

@Query(value = "SELECT COUNT(*) FROM tbl_board " , nativeQuery = true)
int countAllByBoardNum();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface BoardService {

List<BoardCreateAndGetResponse> getPage(BoardPagination pagination);

int getBoardCount();

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ public List<BoardCreateAndGetResponse> getPage(BoardPagination pagination) {
}
return BoardCreateAndGetResponseList;
}

@Override
public int getBoardCount() {
return boardRepository.countAllByBoardNum();
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/dailylife/global/web/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void addInterceptors(InterceptorRegistry registry) {
"/api/users/login",
"/error",
"/boardImg/**",
"/api/board/getBoard/**");
"/api/board/getBoard/**",
"/api/board/getBoardCount");


}
Expand Down

0 comments on commit 475cf4b

Please sign in to comment.