From 668cd65daf2fd7569fdefa3c17370edf1880d400 Mon Sep 17 00:00:00 2001 From: lcaohoanq Date: Tue, 10 Dec 2024 22:29:56 +0700 Subject: [PATCH] chore: remove InventoryLocation --- .../shoppe/base/entity/BaseLocation.java | 2 +- .../shoppe/domain/inventory/Inventory.java | 8 ++------ ...InventoryLocation.java => SubInventory.java} | 17 +++++++---------- 3 files changed, 10 insertions(+), 17 deletions(-) rename SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/{InventoryLocation.java => SubInventory.java} (70%) diff --git a/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/base/entity/BaseLocation.java b/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/base/entity/BaseLocation.java index fc05bf8..332e3c5 100644 --- a/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/base/entity/BaseLocation.java +++ b/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/base/entity/BaseLocation.java @@ -11,7 +11,7 @@ @NoArgsConstructor @AllArgsConstructor @MappedSuperclass -public class BaseLocation { +public class BaseLocation extends BaseEntity { private String name; private String address; diff --git a/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/Inventory.java b/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/Inventory.java index e6cad95..cb435a1 100644 --- a/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/Inventory.java +++ b/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/Inventory.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonProperty; import com.lcaohoanq.shoppe.base.entity.BaseEntity; +import com.lcaohoanq.shoppe.base.entity.BaseLocation; import com.lcaohoanq.shoppe.domain.product.Product; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -28,7 +29,7 @@ @AllArgsConstructor @Table(name = "inventories") @Entity -public class Inventory extends BaseEntity { +public class Inventory extends BaseLocation { @Id @SequenceGenerator(name = "inventories_seq", sequenceName = "inventories_id_seq", allocationSize = 1) @@ -37,11 +38,6 @@ public class Inventory extends BaseEntity { @JsonProperty("id") private Long id; - @JsonManagedReference - @OneToMany(mappedBy = "inventory") - @JsonProperty("inventory_locations") - private Set inventoryLocations; - @OneToMany(mappedBy = "inventory") @JsonManagedReference private Set products; diff --git a/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryLocation.java b/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/SubInventory.java similarity index 70% rename from SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryLocation.java rename to SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/SubInventory.java index 64a74d5..73bb19d 100644 --- a/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/InventoryLocation.java +++ b/SPCServer/springboot/src/main/java/com/lcaohoanq/shoppe/domain/inventory/SubInventory.java @@ -1,7 +1,5 @@ package com.lcaohoanq.shoppe.domain.inventory; - -import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonProperty; import com.lcaohoanq.shoppe.base.entity.BaseLocation; import jakarta.persistence.Column; @@ -19,25 +17,24 @@ import lombok.NoArgsConstructor; import lombok.Setter; +@Entity +@Table(name = "sub_inventories") +@Builder @Getter @Setter -@Builder @NoArgsConstructor @AllArgsConstructor -@Table(name = "inventory_locations") -@Entity -public class InventoryLocation extends BaseLocation { +public class SubInventory extends BaseLocation { @Id - @SequenceGenerator(name = "inventory_locations_seq", sequenceName = "inventory_locations_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "inventory_locations_seq") + @SequenceGenerator(name = "sub_inventories_seq", sequenceName = "sub_inventories_id_seq", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sub_inventories_seq") @Column(name="id", unique=true, nullable=false) @JsonProperty("id") private Long id; @ManyToOne - @JsonBackReference - @JoinColumn(name = "inventory_id", nullable = false) + @JoinColumn(name = "inventory_id") private Inventory inventory; }