Skip to content

Commit

Permalink
chore: 총 페이지 수 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
qormoon committed Jul 14, 2024
1 parent 8228316 commit 26de33b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ public ResponseEntity<List<DictionaryResponseDTO>> searchFlowers(String name) {
return ResponseEntity.ok(flowers);
}

@Override
public ResponseEntity<Integer> getTotalPages(int size) {
int totalPages = dictionaryService.getTotalPages(size);
return ResponseEntity.ok(totalPages);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ public interface DictionaryApi {
@ApiResponse(responseCode = "401", description = "인증 실패")
@GetMapping("/search")
ResponseEntity<List<DictionaryResponseDTO>> searchFlowers(@RequestParam String name);

@Operation(
summary = "총 페이지 수 조회",
description = "전체 꽃 목록의 총 페이지 수를 조회합니다.",
security = @SecurityRequirement(name = "bearerAuth")
)
@ApiResponse(responseCode = "200", description = "총 페이지 수 조회 성공")
@ApiResponse(responseCode = "401", description = "인증 실패")
@GetMapping("/total-pages")
ResponseEntity<Integer> getTotalPages(@RequestParam int size);
}

Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public List<DictionaryResponseDTO> searchFlowersByName(String name) {
.map(DictionaryResponseDTO::of)
.collect(Collectors.toList());
}

public int getTotalPages(int size) {
long count = flowerRepository.count();
return (int) Math.ceil((double) count / size);
}
}

0 comments on commit 26de33b

Please sign in to comment.