From facd0103437ffb50108113567d5fbb24487ffc81 Mon Sep 17 00:00:00 2001 From: mrfoxygmfr Date: Mon, 28 Apr 2025 00:45:36 +0300 Subject: feat: implement storageSlots http controller + pages --- .../http/controllers/StorageSlotsController.java | 96 ++++++++++++++++++++++ src/main/resources/templates/storageSlotEdit.html | 39 +++++++++ src/main/resources/templates/storageSlots.html | 82 ++++++++++++++++++ 3 files changed, 217 insertions(+) create mode 100644 src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java create mode 100644 src/main/resources/templates/storageSlotEdit.html create mode 100644 src/main/resources/templates/storageSlots.html diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java new file mode 100644 index 0000000..2a9b28e --- /dev/null +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java @@ -0,0 +1,96 @@ +package ru.mrfoxygmfr.warehouse_accounting.http.controllers; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import ru.mrfoxygmfr.warehouse_accounting.db.dao.*; +import ru.mrfoxygmfr.warehouse_accounting.db.dao.specs.StorageSlotSpecs; +import ru.mrfoxygmfr.warehouse_accounting.db.models.*; + +import java.util.List; + +@Controller +public class StorageSlotsController { + @Autowired + private StorageSlotDAO storageSlotDAO; + + @GetMapping("storageSlots") + public String storageSlots(@RequestParam(name = "storageSlotHeightLess", required = false) Integer heightLess, + @RequestParam(name = "storageSlotHeightGreater", required = false) Integer heightGreater, + @RequestParam(name = "storageSlotWidthLess", required = false) Integer widthLess, + @RequestParam(name = "storageSlotWidthGreater", required = false) Integer widthGreater, + @RequestParam(name = "storageSlotDepthLess", required = false) Integer depthLess, + @RequestParam(name = "storageSlotDepthGreater", required = false) Integer depthGreater, + Model model) { + Specification spec = Specification.where(null); + if (heightLess != null) { + spec = spec.and(StorageSlotSpecs.storageSlotHeightLess(heightLess)); + model.addAttribute("storageSlotHeightLessFilter", heightLess); + } + if (heightGreater != null) { + spec = spec.and(StorageSlotSpecs.storageSlotHeightGreater(heightGreater)); + model.addAttribute("storageSlotHeightGreaterFilter", heightGreater); + } + if (widthLess != null) { + spec = spec.and(StorageSlotSpecs.storageSlotWidthLess(widthLess)); + model.addAttribute("storageSlotWidthLessFilter", widthLess); + } + if (widthGreater != null) { + spec = spec.and(StorageSlotSpecs.storageSlotWidthGreater(widthGreater)); + model.addAttribute("storageSlotWidthGreaterFilter", widthGreater); + } + if (depthLess != null) { + spec = spec.and(StorageSlotSpecs.storageSlotDepthLess(depthLess)); + model.addAttribute("storageSlotDepthLessFilter", depthLess); + } + if (depthGreater != null) { + spec = spec.and(StorageSlotSpecs.storageSlotDepthGreater(depthGreater)); + model.addAttribute("storageSlotDepthGreaterFilter", depthGreater); + } + + List storageSlots = storageSlotDAO.findAll(spec); + model.addAttribute("storageSlots", storageSlots); + return "storageSlots"; + } + + @GetMapping("storageSlot") + public String storageSlot(@RequestParam(name = "id") Integer id, Model model) { + StorageSlot storageSlot = storageSlotDAO.findById(id).orElseThrow(); + model.addAttribute("storageSlot", storageSlot); + return "storageSlotEdit"; + } + + + @PostMapping("storageSlot") + public String storageSlot(@RequestParam(name = "storageSlotId") Integer id, + @RequestParam(name = "storageSlotLocation") String location, + @RequestParam(name = "storageSlotHeight") Integer height, + @RequestParam(name = "storageSlotWidth") Integer width, + @RequestParam(name = "storageSlotDepth") Integer depth) { + StorageSlot storageSlot; + if (id == -1) { + storageSlot = new StorageSlot(location, height, width, depth); + } else { + storageSlot = storageSlotDAO.findById(id).orElseThrow(); + storageSlot.setLocation(location); + storageSlot.setHeight(height); + storageSlot.setWidth(width); + storageSlot.setDepth(depth); + } + storageSlotDAO.save(storageSlot); + return "redirect:/storageSlots"; + } + + @GetMapping("newStorageSlot") + public String newStorageSlot(Model model) { + StorageSlot storageSlot = new StorageSlot(); + storageSlot.setId(-1); + model.addAttribute("storageSlot", storageSlot); + model.addAttribute("newItem", true); + return "storageSlotEdit"; + } +} diff --git a/src/main/resources/templates/storageSlotEdit.html b/src/main/resources/templates/storageSlotEdit.html new file mode 100644 index 0000000..720a20a --- /dev/null +++ b/src/main/resources/templates/storageSlotEdit.html @@ -0,0 +1,39 @@ + + +
+ + +
+ +
+
+

+
+ +
+ + + +

+ + +

+ + +

+ + +

+ + + +
+
+ + +
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/storageSlots.html b/src/main/resources/templates/storageSlots.html new file mode 100644 index 0000000..3f09ee6 --- /dev/null +++ b/src/main/resources/templates/storageSlots.html @@ -0,0 +1,82 @@ + + +
+ + +
+ +
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Фильтры
Высота + от + до +
Ширина + от + до +
Глубина + от + до +
+
+ + + + + + + + + + + + + + + + + + + +
IDЛокацияГабариты (В*Ш*Г)
Данному фильтру не удовлетворяет ни одного места хранения.
+ + + + + + + +
+
+ +
+
+ + \ No newline at end of file -- cgit mrf-deployment