Упс.Оказывается дтошки то паленые
This commit is contained in:
parent
6f4f19e33f
commit
cf44b6c77c
@ -1,7 +1,7 @@
|
||||
package com.labwork01.app.author.controller;
|
||||
|
||||
import com.labwork01.app.author.model.Author;
|
||||
import com.labwork01.app.book.model.Book;
|
||||
import com.labwork01.app.book.controller.BookDtoWithoutAuthor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -10,13 +10,13 @@ public class AuthorDtoFull {
|
||||
private final String name;
|
||||
private final String surname;
|
||||
private final String patronymic;
|
||||
private final List<Book> books;
|
||||
private final List<BookDtoWithoutAuthor> books;
|
||||
public AuthorDtoFull(Author author){
|
||||
id = author.getId();
|
||||
name = author.getName();
|
||||
surname = author.getSurname();
|
||||
patronymic = author.getPatronymic();
|
||||
books = author.getBooks();
|
||||
books = author.getBooks().stream().map(BookDtoWithoutAuthor::new).toList();
|
||||
}
|
||||
public long getId() {
|
||||
return id;
|
||||
@ -34,7 +34,7 @@ public class AuthorDtoFull {
|
||||
return patronymic;
|
||||
}
|
||||
|
||||
public List<Book> getBooks() {
|
||||
public List<BookDtoWithoutAuthor> getBooks() {
|
||||
return books;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.labwork01.app.book.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.labwork01.app.author.model.Author;
|
||||
import com.labwork01.app.author.controller.AuthorDto;
|
||||
import com.labwork01.app.book.model.Book;
|
||||
import com.labwork01.app.genre.model.Genre;
|
||||
import com.labwork01.app.genre.controller.GenreDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -11,15 +10,14 @@ public class BookDto {
|
||||
private final long id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
@JsonIgnoreProperties("books")
|
||||
private final Author author;
|
||||
private final List<Genre> genres;
|
||||
private final AuthorDto author;
|
||||
private final List<GenreDto> genres;
|
||||
public BookDto(Book book) {
|
||||
this.id = book.getId();
|
||||
this.name = book.getName();
|
||||
this.description = book.getDescription();
|
||||
this.author = book.getAuthor();
|
||||
this.genres = book.getGenres();
|
||||
this.author = new AuthorDto(book.getAuthor());
|
||||
this.genres = book.getGenres().stream().map(GenreDto::new).toList();
|
||||
}
|
||||
public long getId() {
|
||||
return id;
|
||||
@ -32,10 +30,10 @@ public class BookDto {
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public Author getAuthor() {
|
||||
public AuthorDto getAuthor() {
|
||||
return author;
|
||||
}
|
||||
public List<Genre> getGenres(){
|
||||
public List<GenreDto> getGenres(){
|
||||
return genres;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.labwork01.app.book.controller;
|
||||
|
||||
import com.labwork01.app.book.model.Book;
|
||||
import com.labwork01.app.genre.controller.GenreDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BookDtoWithoutAuthor {
|
||||
private final long id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final List<GenreDto> genres;
|
||||
public BookDtoWithoutAuthor(Book book) {
|
||||
this.id = book.getId();
|
||||
this.name = book.getName();
|
||||
this.description = book.getDescription();
|
||||
this.genres = book.getGenres().stream().map(GenreDto::new).toList();
|
||||
}
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public List<GenreDto> getGenres(){
|
||||
return genres;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user