From fcab46dccc86452964821c9e9e68102f3f08caf3 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Wed, 29 May 2024 19:26:57 +0400 Subject: [PATCH] minor fix --- .../java/com/ip/library/books/api/BookController.java | 6 ++++++ .../com/ip/library/users/api/UserBookController.java | 11 +---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/SpringApp/library/src/main/java/com/ip/library/books/api/BookController.java b/SpringApp/library/src/main/java/com/ip/library/books/api/BookController.java index 4d4e914..93ea780 100644 --- a/SpringApp/library/src/main/java/com/ip/library/books/api/BookController.java +++ b/SpringApp/library/src/main/java/com/ip/library/books/api/BookController.java @@ -82,5 +82,11 @@ public class BookController { @PathVariable(name = "bookId") Long bookId, @PathVariable(name = "authorId") Long authorId) { return bookService.addAuthor(authorId, bookId); + } + + @Secured(value = { UserRole.Secured.USER, UserRole.Secured.ADMIN }) + @GetMapping("/{bookId}/number") + public int getBookSubscribersNumber(@PathVariable(name = "bookId") Long bookId) { + return bookService.getBookSubscribersNumber(bookId); } } diff --git a/SpringApp/library/src/main/java/com/ip/library/users/api/UserBookController.java b/SpringApp/library/src/main/java/com/ip/library/users/api/UserBookController.java index 6226093..24e8edc 100644 --- a/SpringApp/library/src/main/java/com/ip/library/users/api/UserBookController.java +++ b/SpringApp/library/src/main/java/com/ip/library/users/api/UserBookController.java @@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.RestController; import com.ip.library.books.api.BookDto; import com.ip.library.books.model.BookEntity; -import com.ip.library.books.service.BookService; import com.ip.library.core.configuration.Constants; import com.ip.library.users.service.UserService; @@ -20,15 +19,12 @@ import com.ip.library.users.service.UserService; public class UserBookController { private final UserService userService; private final ModelMapper modelMapper; - private final BookService bookService; public UserBookController( UserService userService, - ModelMapper modelMapper, - BookService bookService) { + ModelMapper modelMapper) { this.userService = userService; this.modelMapper = modelMapper; - this.bookService = bookService; } private BookDto toBookDto (BookEntity entity) { @@ -51,9 +47,4 @@ public class UserBookController { @RequestParam(name = "size", defaultValue = Constants.DEFAULT_PAGE_SIZE) int size) { return userService.getUserFavorities(userId, page, size).stream().map(this::toBookDto).toList(); } - - @GetMapping("/{bookId}/number") - public int getBookSubscribersNumber(@PathVariable(name = "bookId") Long bookId) { - return bookService.getBookSubscribersNumber(bookId); - } }