From 2404935491aee52355e84fd7a051c6ffe8b821ed Mon Sep 17 00:00:00 2001 From: mrfoxygmfr Date: Mon, 24 Mar 2025 12:21:52 +0300 Subject: feat(db/dao): new productSlot dao --- .../warehouse_accounting/db/dao/ProductSlotDAO.java | 8 ++++++++ .../db/dao/specs/ProductSlotSpecs.java | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/ProductSlotDAO.java create mode 100644 src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/dao/specs/ProductSlotSpecs.java 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, JpaSpecificationExecutor { +} 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 productStorageStatusEqual(ProductStorageStatus status) { + return (root, _, builder) + -> builder.equal(root.get(ProductSlot_.status), status) ; + } + + public static Specification productSlotContainsLike(String productName) { + return (root, _, builder) -> { + Join withProduct = root.join(ProductSlot_.product); + return builder.like(withProduct.get(Product_.name), "%" + productName + "%"); + }; + } +} -- cgit mrf-deployment