Add new entity classes for Categoria, Item, Propiedad, TipoDato, and Ubicacion; update Departamento and User entities for improved relationships and validation
This commit is contained in:
parent
a880ee6d92
commit
cf17b8ed17
|
|
@ -0,0 +1,24 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "categoria")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Categoria {
|
||||
@Id
|
||||
@Column(name = "idcategoria")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String nombre;
|
||||
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import lombok.Setter;
|
|||
@AllArgsConstructor
|
||||
public class Departamento {
|
||||
@Id
|
||||
@Column(name = "iddepartamentos")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY) // ID autoincremental
|
||||
private int id;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "item")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Item {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "iditem")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "fecha_alta")
|
||||
private Date fechaAlta;
|
||||
|
||||
@Column(name = "fecha_modificacion")
|
||||
private Date fechaModificacion;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "users_id")
|
||||
private User usuario;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ubicacion_idubicacion")
|
||||
private Ubicacion ubicacion;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "producto_idproducto")
|
||||
private Producto producto;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "propiedad") // Nombre de la tabla en MySQL
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Propiedad {
|
||||
@Id
|
||||
@Column(name = "idpropiedad")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
private String nombre;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "tipodato_idtipodato")
|
||||
private TipoDato tipoDato;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tipodato")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TipoDato {
|
||||
@Id
|
||||
@Column(name = "idtipodato")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "tipo_dato")
|
||||
private String tipoDato;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ubicacion")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Ubicacion {
|
||||
@Id
|
||||
@Column(name = "idubicacion")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String nombre;
|
||||
|
||||
@Column(nullable = true)
|
||||
private String descripcion;
|
||||
|
||||
@Column(nullable = true)
|
||||
private String notas;
|
||||
}
|
||||
|
|
@ -27,8 +27,9 @@ public class User {
|
|||
@Column(nullable = false, unique = true) // No se permite emails duplicados
|
||||
private String mail;
|
||||
|
||||
@Column(nullable = true)
|
||||
private Integer departamentos_iddepartamentos;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "departamentos_iddepartamentos", nullable = true) // Nombre de la columna en la tabla `users`
|
||||
private Departamento departamento;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "valor")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Valor {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "idvalor")
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String valor;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "propiedad_idpropiedad")
|
||||
private Propiedad propiedad;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "item_iditem")
|
||||
private Item item;
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
|||
|
||||
# Configuración de JPA e Hibernate
|
||||
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
|
||||
#spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.hibernate.ddl-auto=validate
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ DROP TABLE IF EXISTS `inventario`.`ubicacion` ;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `inventario`.`ubicacion` (
|
||||
`idubicacion` INT NOT NULL AUTO_INCREMENT,
|
||||
`nombre` VARCHAR(25) NULL,
|
||||
`nombre` VARCHAR(45) NOT NULL,
|
||||
`descripcion` VARCHAR(100) NULL,
|
||||
`notas` VARCHAR(255) NULL,
|
||||
PRIMARY KEY (`idubicacion`))
|
||||
|
|
@ -109,7 +109,7 @@ DROP TABLE IF EXISTS `inventario`.`categoria` ;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `inventario`.`categoria` (
|
||||
`idcategoria` INT NOT NULL AUTO_INCREMENT,
|
||||
`nombre` VARCHAR(45) NULL,
|
||||
`nombre` VARCHAR(45) NOT NULL,
|
||||
PRIMARY KEY (`idcategoria`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
|
@ -121,10 +121,10 @@ DROP TABLE IF EXISTS `inventario`.`producto` ;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `inventario`.`producto` (
|
||||
`idproducto` INT NOT NULL AUTO_INCREMENT,
|
||||
`nombre` VARCHAR(45) NULL,
|
||||
`productocol` VARCHAR(45) NULL,
|
||||
`nombre` VARCHAR(45) NOT NULL,
|
||||
`categoria_idcategoria` INT NOT NULL,
|
||||
`departamentos_iddepartamentos` INT NOT NULL,
|
||||
`descripcion` VARCHAR(45) NULL,
|
||||
PRIMARY KEY (`idproducto`),
|
||||
INDEX `fk_producto_categoria1_idx` (`categoria_idcategoria` ASC) VISIBLE,
|
||||
INDEX `fk_producto_departamentos1_idx` (`departamentos_iddepartamentos` ASC) VISIBLE,
|
||||
|
|
@ -148,7 +148,7 @@ DROP TABLE IF EXISTS `inventario`.`item` ;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `inventario`.`item` (
|
||||
`iditem` INT NOT NULL AUTO_INCREMENT,
|
||||
`fecha_alta` DATE NULL,
|
||||
`fecha_alta` DATE NOT NULL,
|
||||
`fecha_modificacion` DATE NULL,
|
||||
`users_id` BIGINT NOT NULL,
|
||||
`ubicacion_idubicacion` INT NOT NULL,
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -49,6 +49,8 @@ table {
|
|||
overflow: auto;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
|
||||
}
|
||||
|
||||
.table1 thead {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
<body>
|
||||
<h2>Bienvenido a Gestión de Inventario</h2>
|
||||
<div class="container1">
|
||||
<a href="/Inventario/management">
|
||||
<button>Inventario</button>
|
||||
</a>
|
||||
<!-- Botón visible solo para Administradores -->
|
||||
<div sec:authorize="hasRole('ADMIN')">
|
||||
<a href="/Inventario/management">
|
||||
|
|
|
|||
Loading…
Reference in New Issue