97 lines
1.9 KiB
Java
97 lines
1.9 KiB
Java
package org.example;
|
|
|
|
import jakarta.persistence.*;
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
@Entity
|
|
@Table(name = "reviews")
|
|
public class Review {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@Column(name = "review_id")
|
|
private Long id;
|
|
|
|
@ManyToOne
|
|
@JoinColumn(name = "book_id")
|
|
private Book book;
|
|
|
|
private int rating;
|
|
|
|
@Column(name = "review_text", columnDefinition = "TEXT")
|
|
private String reviewText;
|
|
|
|
@Column(name = "author_name")
|
|
private String authorName;
|
|
|
|
@Column(name = "created_at", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
|
private ZonedDateTime createdAt;
|
|
|
|
public Review() {
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public Book getBook() {
|
|
return book;
|
|
}
|
|
|
|
public void setBook(Book book) {
|
|
this.book = book;
|
|
}
|
|
|
|
public int getRating() {
|
|
return rating;
|
|
}
|
|
|
|
public void setRating(int rating) {
|
|
this.rating = rating;
|
|
}
|
|
|
|
public String getReviewText() {
|
|
return reviewText;
|
|
}
|
|
|
|
public void setReviewText(String reviewText) {
|
|
this.reviewText = reviewText;
|
|
}
|
|
|
|
public String getAuthorName() {
|
|
return authorName;
|
|
}
|
|
|
|
public void setAuthorName(String authorName) {
|
|
this.authorName = authorName;
|
|
}
|
|
|
|
public ZonedDateTime getCreatedAt() {
|
|
if (createdAt == null) {
|
|
createdAt = ZonedDateTime.now();
|
|
}
|
|
|
|
return createdAt;
|
|
}
|
|
|
|
public void setCreatedAt(ZonedDateTime createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Review{" +
|
|
"id=" + id +
|
|
", book=" + book +
|
|
", rating=" + rating +
|
|
", reviewText='" + reviewText +
|
|
", authorName='" + authorName +
|
|
'}';
|
|
}
|
|
}
|