Commit 868e37b3 by Rubén Ramírez

feat: [Genero-Recurso]: Hecha la relación entre Género y Recurso y modificado el ER

parent e41e31d6
......@@ -23,6 +23,11 @@ entity "Recurso" as Recurso {
autor : String
}
entity "Genero" as Genero {
*recurso_id : Integer
genero : String
}
entity "Categoria" as Categoria {
*id : Integer
nombre : String
......@@ -34,17 +39,6 @@ entity "Repositorio_Recurso" as RepositorioRecurso {
categoria_id : Integer
}
entity "Genero" as Genero {
*id : Integer
--
nombre : String
}
entity "Recurso_Genero" as RecursoGenero {
*recurso_id : Integer
*genero_id : Integer
}
entity "Capitulo" as Capitulo {
*id : Integer
--
......@@ -60,9 +54,9 @@ Usuario ||--o{ Repositorio : "tiene"
Repositorio ||--o{ RepositorioRecurso : "contiene"
Recurso ||--o{ RepositorioRecurso : "almacenado en"
RepositorioRecurso }|--|| Categoria : "clasificado en"
Recurso ||--o{ RecursoGenero : "clasificado como"
Genero ||--o{ RecursoGenero : "pertenece a"
Recurso ||--o{ Capitulo : "contiene"
' Corrección: Un recurso puede tener varios géneros
Recurso ||--o{ Genero : "tiene varios"
@enduml
package com.ujaen.tfg.mangaffinity.entidades;
import jakarta.persistence.*;
import lombok.*;
import jakarta.validation.constraints.NotBlank;
@Entity
@Table(name = "generos")
@Getter
@NoArgsConstructor
public class Genero {
@Id
@NotBlank
@Column(nullable = false, unique = true)
private String nombre;
public Genero(String nombre) {
this.nombre = nombre;
}
}
\ No newline at end of file
public enum Genero {
ACCION,
AVENTURA,
COMEDIA,
DRAMA,
FANTASIA,
HORROR,
CIENCIA_FICCION,
ROMANCE,
DEPORTES
}
......@@ -5,7 +5,8 @@ import lombok.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
@Entity
......@@ -35,6 +36,11 @@ public class Recurso {
@Column(nullable = false)
private String autor;
@ElementCollection(targetClass = Genero.class)
@Enumerated(EnumType.STRING)
@CollectionTable(name = "recurso_genero", joinColumns = @JoinColumn(name = "recurso_id"))
@Column(name = "genero")
private Set<Genero> generos = new HashSet<>();
// Constructor con parámetros obligatorios
public Recurso(String titulo, String descripcion, LocalDate fechaPublicacion, String autor) {
......
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