aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrfoxygmfr <mrfoxygmfr@sch9.ru>2025-03-17 12:25:34 +0300
committermrfoxygmfr <mrfoxygmfr@sch9.ru>2025-03-17 12:25:34 +0300
commitaccfb4ee23b59b6f9f4bdaf0f91b88c79f4c5b3e (patch)
treeb9f2db4a8cc00c48f6cc98ae3ecab8aadf587f50
parentef2bec524581a63d989fc3de70433a118bd905fa (diff)
feat(db): add models
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java58
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java33
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationStatus.java5
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationType.java6
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java36
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java44
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerType.java6
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java44
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java45
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductStorageStatus.java5
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductType.java5
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java35
12 files changed, 322 insertions, 0 deletions
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java
new file mode 100644
index 0000000..01e082a
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java
@@ -0,0 +1,58 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "operations")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class Operation {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "partner_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private Partner partner;
+
+ @Column(nullable = false, name = "type")
+ @Enumerated(EnumType.STRING)
+ @NonNull
+ private OperationType type;
+
+ @Column(nullable = false, name = "status")
+ @Enumerated(EnumType.ORDINAL)
+ @NonNull
+ private OperationStatus status;
+
+ @Column(nullable = false, name = "date_created")
+ @NonNull
+ private Timestamp date_created;
+
+ @Column(nullable = false, name = "date_modified")
+ @NonNull
+ private Timestamp date_modified;
+
+ @Column(nullable = false, name = "date_finished")
+ @NonNull
+ private Timestamp date_finished;
+
+
+ @Column(nullable = false, name = "address")
+ @NonNull
+ private String address;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "responsible_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private PartnerContact responsible;
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java
new file mode 100644
index 0000000..9eaeab1
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java
@@ -0,0 +1,33 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Table(name = "operation_products")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class OperationProducts {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "operation_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private Operation operation;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "product_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private Product product;
+
+ @Column(nullable = false, name = "amount")
+ @NonNull
+ private long amount;
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationStatus.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationStatus.java
new file mode 100644
index 0000000..db8634a
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationStatus.java
@@ -0,0 +1,5 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+public enum OperationStatus {
+ OPEN
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationType.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationType.java
new file mode 100644
index 0000000..b3ee0b0
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationType.java
@@ -0,0 +1,6 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+public enum OperationType {
+ SUPPLY,
+ ISSUE
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java
new file mode 100644
index 0000000..6d1859d
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java
@@ -0,0 +1,36 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Table(name = "partners")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class Partner {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+ @Column(nullable = false, name = "name")
+ @NonNull
+ private String name;
+
+ @Column(nullable = false, name = "tax_number")
+ @NonNull
+ private String tax_number;
+
+ @Column(nullable = false, name = "type")
+ @Enumerated(EnumType.STRING)
+ @NonNull
+ private PartnerType type;
+
+ @Column(nullable = false, name = "address")
+ @NonNull
+ private String address;
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java
new file mode 100644
index 0000000..e25d178
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java
@@ -0,0 +1,44 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Table(name = "partner_contacts")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class PartnerContact {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "partner_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private Partner partner;
+
+ @Column(nullable = false, name = "surname")
+ @NonNull
+ private String surname;
+
+ @Column(nullable = false, name = "name")
+ @NonNull
+ private String name;
+
+ @Column(nullable = false, name = "position")
+ @NonNull
+ private String position;
+
+ @Column(nullable = false, name = "phone")
+ @NonNull
+ private String phone;
+
+ @Column(nullable = false, name = "email")
+ @NonNull
+ private String email;
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerType.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerType.java
new file mode 100644
index 0000000..ad6e4a6
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerType.java
@@ -0,0 +1,6 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+public enum PartnerType {
+ SUPPLIER,
+ ISSUER
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java
new file mode 100644
index 0000000..34b4c5a
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java
@@ -0,0 +1,44 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+import java.time.Duration;
+
+
+@Entity
+@Table(name = "products")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class Product {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+ @Column(nullable = false, name = "type")
+ @Enumerated(EnumType.ORDINAL)
+ @NonNull
+ private ProductType type;
+
+ @Column(nullable = false, name = "height")
+ @NonNull
+ private long height;
+
+ @Column(nullable = false, name = "width")
+ @NonNull
+ private long width;
+
+ @Column(nullable = false, name = "depth")
+ @NonNull
+ private long depth;
+
+ @Column(nullable = true, name = "max_storage_duration", columnDefinition = "interval")
+ @NonNull
+ private Duration max_storage_duration;
+}
+
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java
new file mode 100644
index 0000000..b3a19a1
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java
@@ -0,0 +1,45 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "product_slots")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class ProductSlots {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "product_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private Product product;
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "slot_id", referencedColumnName = "id", insertable = false, updatable = false)
+ @NonNull
+ private StorageSlot slot;
+
+ @Column(nullable = false, name = "amount")
+ @NonNull
+ private long amount;
+
+ @Column(nullable = false, name = "status")
+ @Enumerated(EnumType.ORDINAL)
+ @NonNull
+ private ProductStorageStatus status;
+
+ @Column(nullable = false, name = "placement_time")
+ @NonNull
+ private Timestamp placement_time;
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductStorageStatus.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductStorageStatus.java
new file mode 100644
index 0000000..6e07508
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductStorageStatus.java
@@ -0,0 +1,5 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+public enum ProductStorageStatus {
+ PLACED,
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductType.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductType.java
new file mode 100644
index 0000000..499363f
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductType.java
@@ -0,0 +1,5 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+public enum ProductType {
+ FOOD
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java
new file mode 100644
index 0000000..7486b21
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java
@@ -0,0 +1,35 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.models;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Table(name = "storage_slots")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@RequiredArgsConstructor
+@AllArgsConstructor
+public class StorageSlot {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(nullable = false, name = "id")
+ private int id;
+
+ @Column(nullable = false, name = "location")
+ @NonNull
+ private String location;
+
+ @Column(nullable = false, name = "height")
+ @NonNull
+ private long height;
+
+ @Column(nullable = false, name = "width")
+ @NonNull
+ private long width;
+
+ @Column(nullable = false, name = "depth")
+ @NonNull
+ private long depth;
+}