Commit b5ed5727 by Rubén Ramírez

feat: [Reseña]: Creada la clase para tener reseñas

parent 90fb14c0
package com.ujaen.tfg.mangaffinity.entidades;
import jakarta.persistence.*;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
@Entity
@Table(name = "resenas")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Resena {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "usuario_id", nullable = false)
private Usuario usuario;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "recurso_id", nullable = false)
private Recurso recurso;
@NotNull
@Column(nullable = false)
private LocalDate fechaPublicacion;
@NotNull
@Min(1)
@Max(5)
@Column(nullable = false)
private int estrellas;
@NotBlank
@Column(nullable = false)
private String texto;
public Resena(Usuario usuario, Recurso recurso, int estrellas, String texto) {
this.usuario = usuario;
this.recurso = recurso;
this.fechaPublicacion = LocalDate.now();
this.estrellas = estrellas;
this.texto = texto;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment