From 2394157be8b2c885686cafd3359a9777fcccc318 Mon Sep 17 00:00:00 2001 From: Hannes Date: Mon, 1 Jun 2020 11:31:12 +0200 Subject: [PATCH] implement getCustomerOrder --- .../hso/ecommerce/app/RequestController.java | 10 ----- .../customers/CustomerOrderController.java | 25 +++++++++++- .../repos/shop/CustomerOderRepository.java | 4 ++ .../intern/customerOrders/index.html | 39 ++++--------------- 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java index bb0b5d6..17b351e 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java @@ -90,16 +90,6 @@ public class RequestController { return "intern/customers/id"; } - @GetMapping("/intern/customerOrders/") - public String internCustomerOrder() { - return "intern/customerOrders/index"; - } - - @GetMapping("/intern/customerOrders/{id}") - public String internCustomerOrdersId() { - return "intern/customerOrders/id"; - } - @GetMapping("/intern/suppliers/") public String internSuppliers() { return "intern/suppliers/index"; diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java index 1cea63e..fdc4275 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/customers/CustomerOrderController.java @@ -1,8 +1,31 @@ package org.hso.ecommerce.controller.intern.customers; +import org.hso.ecommerce.entities.shop.CustomerOrder; +import org.hso.ecommerce.repos.shop.CustomerOderRepository; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; @Controller -//@RequestMapping("...") +@RequestMapping("intern/customerOrders") public class CustomerOrderController { + + @Autowired + private final CustomerOderRepository customerOrderRepository = null; + + @GetMapping("") + public String internCustomerOrder(Model model) { + List orders = customerOrderRepository.getAllOrders(); + model.addAttribute("orders", orders); + return "intern/customerOrders/index"; + } + + @GetMapping("/{id}") + public String internCustomerOrdersId() { + return "intern/customerOrders/id"; + } } diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOderRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOderRepository.java index 2c332f5..2bebc41 100644 --- a/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOderRepository.java +++ b/prototype/src/main/java/org/hso/ecommerce/repos/shop/CustomerOderRepository.java @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface CustomerOderRepository extends JpaRepository { @@ -13,5 +15,7 @@ public interface CustomerOderRepository extends JpaRepository getAllOrders(); } diff --git a/prototype/src/main/resources/templates/intern/customerOrders/index.html b/prototype/src/main/resources/templates/intern/customerOrders/index.html index 30923cf..987fce5 100644 --- a/prototype/src/main/resources/templates/intern/customerOrders/index.html +++ b/prototype/src/main/resources/templates/intern/customerOrders/index.html @@ -40,37 +40,14 @@ Status - - 101 - 440 - 2019-12-54 - 10,13 EUR - Zugestellt - Details - - - 102 - 241 - 2019-11-10 - 40,13 EUR - In Zustellung - Details - - - 101 - 241 - 2019-11-10 - 10,13 EUR - Erfasst - Details - - - 755 - 544 - 2019-12-10 - 45,13 EUR - Erfasst - Details + + 101 + + + + In Zustellung + Zugestellt + Details