From 426e1100fcd681852b1a0c6a02852f6e1d90cbcf Mon Sep 17 00:00:00 2001 From: Mathis Kral Date: Sun, 5 Nov 2023 10:39:39 +0100 Subject: [PATCH] Add OrderController, CustomOrder, CustomOrderRepository --- src/main/java/catering/order/CustomOrder.java | 47 +++++++++++++++++++ .../catering/order/CustomOrderRepository.java | 27 +++++++++++ .../java/catering/order/OrderController.java | 8 ++++ 3 files changed, 82 insertions(+) create mode 100644 src/main/java/catering/order/CustomOrder.java create mode 100644 src/main/java/catering/order/CustomOrderRepository.java create mode 100644 src/main/java/catering/order/OrderController.java diff --git a/src/main/java/catering/order/CustomOrder.java b/src/main/java/catering/order/CustomOrder.java new file mode 100644 index 0000000..e03d5ec --- /dev/null +++ b/src/main/java/catering/order/CustomOrder.java @@ -0,0 +1,47 @@ +package catering.order; + +import org.aspectj.weaver.ast.Or; +import org.salespointframework.quantity.Quantity; + +import java.util.Map; + +/** + * This class is only used for the prototype to avoid using the bloated Salespoint API + */ +public class CustomOrder { + + private OrderType orderType; + private Map products; + private boolean invoiceAvailable; + private double totalCost; // this is in € + + public CustomOrder(OrderType orderType, Map products, boolean invoiceAvailable, double totalCost) { + this.orderType = orderType; + this.products = products; + this.invoiceAvailable = invoiceAvailable; + this.totalCost = totalCost; + } + + public OrderType getOrderType() { + return orderType; + } + + public Map getProducts() { + return products; + } + + public boolean isInvoiceAvailable() { + return invoiceAvailable; + } + + public double getTotalCost() { + return totalCost; + } + + private enum OrderType { + RENT_A_COOK, + EVENT_CATERING, + SUSHI_NIGHT, + SOMETHING_ELSE + } +} diff --git a/src/main/java/catering/order/CustomOrderRepository.java b/src/main/java/catering/order/CustomOrderRepository.java new file mode 100644 index 0000000..15776cc --- /dev/null +++ b/src/main/java/catering/order/CustomOrderRepository.java @@ -0,0 +1,27 @@ +package catering.order; + +import java.util.HashSet; +import java.util.Set; + +/** + * This class is only used for the prototype to avoid using the bloated Salespoint API + */ +public class CustomOrderRepository { + private Set orders; + + public CustomOrderRepository() { + this.orders = new HashSet<>(); + } + + public boolean addOrder(CustomOrder order) { + return this.orders.add(order); + } + + public boolean removeOrder(CustomOrder order) { + return this.orders.remove(order); + } + + public Set getOrders() { + return this.orders; + } +} diff --git a/src/main/java/catering/order/OrderController.java b/src/main/java/catering/order/OrderController.java new file mode 100644 index 0000000..533d5c9 --- /dev/null +++ b/src/main/java/catering/order/OrderController.java @@ -0,0 +1,8 @@ +package catering.order; + +import org.springframework.stereotype.Controller; + +@Controller +public class OrderController { + +}