diff --git a/SpringApp/library/src/main/java/com/ip/library/controllers/users/UserBookController.java b/SpringApp/library/src/main/java/com/ip/library/controllers/users/UserBookController.java index a407187..48b25f9 100644 --- a/SpringApp/library/src/main/java/com/ip/library/controllers/users/UserBookController.java +++ b/SpringApp/library/src/main/java/com/ip/library/controllers/users/UserBookController.java @@ -32,6 +32,7 @@ public class UserBookController { private static final String AUTHORS_ATTRIBUTE = "authors"; private static final String TYPE_ATTRIBUTE = "typeId"; private static final String TYPES_ATTRIBUTE = "types"; + private static final String PARAMS_ATTRIBUTE = "searchParams"; private final UserService userService; private final BookService bookService; @@ -70,7 +71,7 @@ public class UserBookController { } @GetMapping - public String getFavorites( + public String favorites( @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, Model model, @AuthenticationPrincipal UserPrincipal principal) { @@ -94,7 +95,7 @@ public class UserBookController { } @GetMapping(Constants.API_URL + "/search") - public String getAll( + public String search( @RequestParam(name = PAGE_ATTRIBUTE, defaultValue = "0") int page, @RequestParam(name = TYPE_ATTRIBUTE, defaultValue = "-1") Long typeId, @RequestParam(name = AUTHOR_ATTRIBUTE, defaultValue = "-1") Long authorId, @@ -107,6 +108,7 @@ public class UserBookController { model.addAttribute(AUTHOR_ATTRIBUTE, authorId); model.addAttribute(TYPES_ATTRIBUTE, typeService.getAll()); model.addAttribute(AUTHORS_ATTRIBUTE, authorService.getAll()); + model.addAttribute(PARAMS_ATTRIBUTE, "typeId="+typeId+"&authorId="+authorId); model.addAttribute(PAGE_ATTRIBUTE, page); return BOOK_SEARCH_VIEW; } diff --git a/SpringApp/library/src/main/resources/templates/book-search.html b/SpringApp/library/src/main/resources/templates/book-search.html index 5dd97c8..bc3c41b 100644 --- a/SpringApp/library/src/main/resources/templates/book-search.html +++ b/SpringApp/library/src/main/resources/templates/book-search.html @@ -65,10 +65,8 @@ url=${'api/1.0/search'}, totalPages=${totalPages}, currentPage=${currentPage}, - param1name=${'typeId'}, - param1value=${typeId}, - param2name=${'authorId'}, - param2value=${authorId}) }" /> + searchParams=${searchParams} + )}" /> diff --git a/SpringApp/library/src/main/resources/templates/pagination.html b/SpringApp/library/src/main/resources/templates/pagination.html index 6d9c959..a2e6e73 100644 --- a/SpringApp/library/src/main/resources/templates/pagination.html +++ b/SpringApp/library/src/main/resources/templates/pagination.html @@ -48,7 +48,7 @@ - +