mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add OrderController, CustomOrder, CustomOrderRepository
This commit is contained in:
parent
5f04f2e1b8
commit
5b4aaec73a
47
src/main/java/catering/order/CustomOrder.java
Normal file
47
src/main/java/catering/order/CustomOrder.java
Normal 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
|
||||||
|
}
|
||||||
|
}
|
27
src/main/java/catering/order/CustomOrderRepository.java
Normal file
27
src/main/java/catering/order/CustomOrderRepository.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
8
src/main/java/catering/order/OrderController.java
Normal file
8
src/main/java/catering/order/OrderController.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package catering.order;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class OrderController {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue