76 lines
1.5 KiB
Java
76 lines
1.5 KiB
Java
package pl.edu.amu.wmi.bookapi.models;
|
|
|
|
import org.springframework.data.annotation.Id;
|
|
import org.springframework.data.mongodb.core.mapping.Document;
|
|
import pl.edu.amu.wmi.bookapi.api.dto.BookDto;
|
|
|
|
@Document
|
|
public class BookDocument {
|
|
|
|
@Id
|
|
private String id;
|
|
private String ownerUsername;
|
|
private String ean;
|
|
private String author;
|
|
private String title;
|
|
|
|
public BookDocument() {
|
|
}
|
|
|
|
public BookDocument(String ownerUsername, String ean, String author, String title) {
|
|
this.ownerUsername = ownerUsername;
|
|
this.ean = ean;
|
|
this.author = author;
|
|
this.title = title;
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getOwnerUsername() {
|
|
return ownerUsername;
|
|
}
|
|
|
|
public void setOwnerUsername(String ownerUsername) {
|
|
this.ownerUsername = ownerUsername;
|
|
}
|
|
|
|
public String getEan() {
|
|
return ean;
|
|
}
|
|
|
|
public void setEan(String ean) {
|
|
this.ean = ean;
|
|
}
|
|
|
|
public String getAuthor() {
|
|
return author;
|
|
}
|
|
|
|
public void setAuthor(String author) {
|
|
this.author = author;
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public void setTitle(String title) {
|
|
this.title = title;
|
|
}
|
|
|
|
public static BookDocument from(String userName, BookDto bookDto) {
|
|
return new BookDocument(
|
|
userName,
|
|
bookDto.getEan(),
|
|
bookDto.getAuthor(),
|
|
bookDto.getTitle()
|
|
);
|
|
}
|
|
}
|