Add Producto entity and establish relationships with Categoria, Departamento, and Item; update existing entities to include new relationships
This commit is contained in:
parent
cf17b8ed17
commit
0551d35bab
|
|
@ -6,6 +6,8 @@ import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "categoria")
|
@Table(name = "categoria")
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -21,4 +23,8 @@ public class Categoria {
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String nombre;
|
private String nombre;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "categoria")
|
||||||
|
private List<Producto> productos;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "departamentos") // Nombre de la tabla en MySQL
|
@Table(name = "departamentos") // Nombre de la tabla en MySQL
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -21,4 +23,9 @@ public class Departamento {
|
||||||
@Column(nullable = false, unique = true) // No se permite usuarios duplicados
|
@Column(nullable = false, unique = true) // No se permite usuarios duplicados
|
||||||
private String nombre;
|
private String nombre;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "departamento")
|
||||||
|
private List<Producto> productos;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "departamento")
|
||||||
|
private List<User> usuarios;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,44 @@
|
||||||
package com.ieslamar.GestionInventario.entities;
|
package com.ieslamar.GestionInventario.entities;
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "item")
|
@Table(name = "item") // Nombre de la tabla en MySQL
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Item {
|
public class Item {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "iditem")
|
@Column(name = "iditem")
|
||||||
private Long id;
|
private Integer id;
|
||||||
|
|
||||||
@Column(name = "fecha_alta")
|
@Column(name = "fecha_alta",nullable = false)
|
||||||
private Date fechaAlta;
|
private Date fechaAlta;
|
||||||
|
|
||||||
@Column(name = "fecha_modificacion")
|
@Column(name = "fecha_modificacion")
|
||||||
private Date fechaModificacion;
|
private Date fechaModificacion;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "users_id")
|
@JoinColumn(name = "users_id", nullable = false)
|
||||||
private User usuario;
|
private User user;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "producto_idproducto")
|
||||||
|
private Producto producto;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "ubicacion_idubicacion")
|
@JoinColumn(name = "ubicacion_idubicacion")
|
||||||
private Ubicacion ubicacion;
|
private Ubicacion ubicacion;
|
||||||
|
|
||||||
@ManyToOne
|
@OneToMany(mappedBy = "item")
|
||||||
@JoinColumn(name = "producto_idproducto")
|
private List<Valor> valores;
|
||||||
private Producto producto;
|
}
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ieslamar.GestionInventario.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "producto") // Nombre de la tabla en MySQL
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Producto {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "idproducto")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(name = "nombre",nullable = false)
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String descripcion;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "departamentos_iddepartamentos")
|
||||||
|
private Departamento departamento;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "categoria_idcategoria")
|
||||||
|
private Categoria categoria;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "producto")
|
||||||
|
private List<Item> items;
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,8 @@ import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "propiedad") // Nombre de la tabla en MySQL
|
@Table(name = "propiedad") // Nombre de la tabla en MySQL
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -23,4 +25,7 @@ public class Propiedad {
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "tipodato_idtipodato")
|
@JoinColumn(name = "tipodato_idtipodato")
|
||||||
private TipoDato tipoDato;
|
private TipoDato tipoDato;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "priopiedad")
|
||||||
|
private List<Valor> valores;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "tipodato")
|
@Table(name = "tipodato")
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -20,4 +22,7 @@ public class TipoDato {
|
||||||
|
|
||||||
@Column(name = "tipo_dato")
|
@Column(name = "tipo_dato")
|
||||||
private String tipoDato;
|
private String tipoDato;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "tipoDato")
|
||||||
|
private List<Propiedad> propiedades;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ubicacion")
|
@Table(name = "ubicacion")
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -26,4 +29,8 @@ public class Ubicacion {
|
||||||
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
private String notas;
|
private String notas;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "ubicacion")
|
||||||
|
private List<Item> items;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.ieslamar.GestionInventario.entities;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "users") // Nombre de la tabla en MySQL
|
@Table(name = "users") // Nombre de la tabla en MySQL
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -27,9 +29,8 @@ public class User {
|
||||||
@Column(nullable = false, unique = true) // No se permite emails duplicados
|
@Column(nullable = false, unique = true) // No se permite emails duplicados
|
||||||
private String mail;
|
private String mail;
|
||||||
|
|
||||||
@ManyToOne
|
@OneToMany(mappedBy = "user")
|
||||||
@JoinColumn(name = "departamentos_iddepartamentos", nullable = true) // Nombre de la columna en la tabla `users`
|
private List<Item> items;
|
||||||
private Departamento departamento;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,26 @@
|
||||||
package com.ieslamar.GestionInventario.entities;
|
package com.ieslamar.GestionInventario.entities;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "valor")
|
@Table(name = "valor") // Nombre de la tabla en MySQL
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Valor {
|
public class Valor {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "idvalor")
|
@Column(name = "idvalor")
|
||||||
private Long id;
|
private Integer id;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column
|
||||||
private String valor;
|
private String valor;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue