diff --git a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/AuthorMvcController.java b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/AuthorMvcController.java index 110ee85..374ee73 100644 --- a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/AuthorMvcController.java +++ b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/AuthorMvcController.java @@ -55,7 +55,7 @@ public class AuthorMvcController { } authorDto.setPhoto("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); if (id == null || id <= 0) { - authorService.addAuthor(authorDto); + return "redirect:/author/" + authorService.addAuthor(authorDto).getId().toString() + "/books"; } else { authorService.updateAuthor(id, authorDto); } diff --git a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookDto.java b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookDto.java index 26caf34..6754a9b 100644 --- a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookDto.java +++ b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookDto.java @@ -1,5 +1,6 @@ package ru.ip.labworks.labworks.bookshop.controller; +import org.springframework.format.annotation.DateTimeFormat; import ru.ip.labworks.labworks.bookshop.model.Book; import java.nio.charset.StandardCharsets; @@ -8,6 +9,7 @@ import java.util.Date; public class BookDto { private Long id; private String name; + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date release; private String cover; diff --git a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookMvcController.java b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookMvcController.java index 6818846..16e39af 100644 --- a/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookMvcController.java +++ b/src/main/java/ru/ip/labworks/labworks/bookshop/controller/BookMvcController.java @@ -54,7 +54,7 @@ public class BookMvcController { } bookDto.setCover("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); if (id == null || id <= 0) { - bookService.addBook(bookDto); + return "redirect:/book/" + bookService.addBook(bookDto).getId().toString() + "/genres"; } else { bookService.updateBook(id, bookDto); }