From 9df9926503db93c9f1dfcbebae8575b9519dcd03 Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Mon, 15 May 2023 22:05:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labworks/bookshop/controller/AuthorMvcController.java | 2 +- .../ru/ip/labworks/labworks/bookshop/controller/BookDto.java | 2 ++ .../labworks/bookshop/controller/BookMvcController.java | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) 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); }