готово

This commit is contained in:
maxnes3 2023-05-15 22:05:28 +04:00
parent 72128f189c
commit 9df9926503
3 changed files with 4 additions and 2 deletions

View File

@ -55,7 +55,7 @@ public class AuthorMvcController {
} }
authorDto.setPhoto("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); authorDto.setPhoto("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes()));
if (id == null || id <= 0) { if (id == null || id <= 0) {
authorService.addAuthor(authorDto); return "redirect:/author/" + authorService.addAuthor(authorDto).getId().toString() + "/books";
} else { } else {
authorService.updateAuthor(id, authorDto); authorService.updateAuthor(id, authorDto);
} }

View File

@ -1,5 +1,6 @@
package ru.ip.labworks.labworks.bookshop.controller; package ru.ip.labworks.labworks.bookshop.controller;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ip.labworks.labworks.bookshop.model.Book; import ru.ip.labworks.labworks.bookshop.model.Book;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -8,6 +9,7 @@ import java.util.Date;
public class BookDto { public class BookDto {
private Long id; private Long id;
private String name; private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date release; private Date release;
private String cover; private String cover;

View File

@ -54,7 +54,7 @@ public class BookMvcController {
} }
bookDto.setCover("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); bookDto.setCover("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes()));
if (id == null || id <= 0) { if (id == null || id <= 0) {
bookService.addBook(bookDto); return "redirect:/book/" + bookService.addBook(bookDto).getId().toString() + "/genres";
} else { } else {
bookService.updateBook(id, bookDto); bookService.updateBook(id, bookDto);
} }