Add OrderController, CustomOrder, CustomOrderRepository

This commit is contained in:
Mathis Kral 2023-11-05 10:39:39 +01:00 committed by Simon Bruder
parent 5f04f2e1b8
commit 5b4aaec73a
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
3 changed files with 82 additions and 0 deletions

View file

@ -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<String, Quantity> products;
private boolean invoiceAvailable;
private double totalCost; // this is in
public CustomOrder(OrderType orderType, Map<String, Quantity> products, boolean invoiceAvailable, double totalCost) {
this.orderType = orderType;
this.products = products;
this.invoiceAvailable = invoiceAvailable;
this.totalCost = totalCost;
}
public OrderType getOrderType() {
return orderType;
}
public Map<String, Quantity> 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
}
}

View file

@ -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<CustomOrder> 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<CustomOrder> getOrders() {
return this.orders;
}
}

View file

@ -0,0 +1,8 @@
package catering.order;
import org.springframework.stereotype.Controller;
@Controller
public class OrderController {
}