aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrfoxygmfr <mrfoxygmfr@sch9.ru>2025-03-24 12:21:52 +0300
committermrfoxygmfr <mrfoxygmfr@sch9.ru>2025-03-24 12:21:52 +0300
commit2404935491aee52355e84fd7a051c6ffe8b821ed (patch)
tree9c44b6f871191530dc2e2bf7498a4f4f9a39da82
parent63303b61b6810b76cd16e2ad2c72b9e527813c28 (diff)
feat(db/dao): new productSlot dao
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/ProductSlotDAO.java8
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/specs/ProductSlotSpecs.java19
2 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/ProductSlotDAO.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/ProductSlotDAO.java
new file mode 100644
index 0000000..469bf2a
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/ProductSlotDAO.java
@@ -0,0 +1,8 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.dao;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import ru.mrfoxygmfr.warehouse_accounting.db.models.ProductSlot;
+
+public interface ProductSlotDAO extends JpaRepository<ProductSlot, Integer>, JpaSpecificationExecutor<ProductSlot> {
+}
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/specs/ProductSlotSpecs.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/specs/ProductSlotSpecs.java
new file mode 100644
index 0000000..2a8e448
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/specs/ProductSlotSpecs.java
@@ -0,0 +1,19 @@
+package ru.mrfoxygmfr.warehouse_accounting.db.dao.specs;
+
+import jakarta.persistence.criteria.Join;
+import org.springframework.data.jpa.domain.Specification;
+import ru.mrfoxygmfr.warehouse_accounting.db.models.*;
+
+public class ProductSlotSpecs {
+ public static Specification<ProductSlot> productStorageStatusEqual(ProductStorageStatus status) {
+ return (root, _, builder)
+ -> builder.equal(root.get(ProductSlot_.status), status) ;
+ }
+
+ public static Specification<ProductSlot> productSlotContainsLike(String productName) {
+ return (root, _, builder) -> {
+ Join<ProductSlot, Product> withProduct = root.join(ProductSlot_.product);
+ return builder.like(withProduct.get(Product_.name), "%" + productName + "%");
+ };
+ }
+}