mirror of
https://github.com/booklore-app/booklore.git
synced 2026-02-18 00:17:53 +01:00
show session numbers in book (#2696)
This commit is contained in:
@@ -37,8 +37,11 @@ public class ReadingSessionController {
|
||||
@ApiResponse(responseCode = "404", description = "Book not found")
|
||||
})
|
||||
@GetMapping("/book/{bookId}")
|
||||
public ResponseEntity<Page<ReadingSessionResponse>> getReadingSessionsForBook(@PathVariable Long bookId, @RequestParam(defaultValue = "0") int page) {
|
||||
Page<ReadingSessionResponse> sessions = readingSessionService.getReadingSessionsForBook(bookId, page);
|
||||
public ResponseEntity<Page<ReadingSessionResponse>> getReadingSessionsForBook(
|
||||
@PathVariable Long bookId,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "5") int size) {
|
||||
Page<ReadingSessionResponse> sessions = readingSessionService.getReadingSessionsForBook(bookId, page, size);
|
||||
return ResponseEntity.ok(sessions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,13 +244,13 @@ public class ReadingSessionService {
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Page<ReadingSessionResponse> getReadingSessionsForBook(Long bookId, int page) {
|
||||
public Page<ReadingSessionResponse> getReadingSessionsForBook(Long bookId, int page, int size) {
|
||||
BookLoreUser authenticatedUser = authenticationService.getAuthenticatedUser();
|
||||
Long userId = authenticatedUser.getId();
|
||||
|
||||
bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
|
||||
|
||||
Pageable pageable = PageRequest.of(page, 5);
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
Page<ReadingSessionEntity> sessions = readingSessionRepository.findByUserIdAndBookId(userId, bookId, pageable);
|
||||
|
||||
return sessions.map(session -> ReadingSessionResponse.builder()
|
||||
|
||||
Reference in New Issue
Block a user