mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Make orderCatalog use OrderType
This commit is contained in:
parent
2248e8eeef
commit
317af597f5
|
@ -1,5 +1,6 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import catering.order.OrderType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -17,7 +18,7 @@ public class CatalogController {
|
|||
public CatalogController(CustomCatalogEntryRepository catalogEntryRepository) {
|
||||
inventory = new HashSet<>();
|
||||
formCatalogEntry = new CustomCatalogEntry(
|
||||
CustomCatalogEntry.EventType.EVENT_CATERING,
|
||||
OrderType.EVENT_CATERING,
|
||||
new HashMap<String, Integer>(),
|
||||
0,
|
||||
0);
|
||||
|
@ -38,7 +39,7 @@ public class CatalogController {
|
|||
}
|
||||
|
||||
@PostMapping("/catalog_editor/catalog_add")
|
||||
public String catalog_add(@RequestParam CustomCatalogEntry.EventType eventType,
|
||||
public String catalog_add(@RequestParam OrderType eventType,
|
||||
@RequestParam int minimumTimePeriod,
|
||||
@RequestParam int totalCost,
|
||||
Model model) {
|
||||
|
@ -48,14 +49,13 @@ public class CatalogController {
|
|||
products.put(product.getName(), product.getAmount());
|
||||
}
|
||||
|
||||
System.out.println("Products looks like this:" + products);
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(
|
||||
eventType,
|
||||
products,
|
||||
minimumTimePeriod,
|
||||
totalCost));
|
||||
this.formCatalogEntry = new CustomCatalogEntry(
|
||||
CustomCatalogEntry.EventType.EVENT_CATERING,
|
||||
OrderType.EVENT_CATERING,
|
||||
new HashMap<String, Integer>(),
|
||||
0,
|
||||
0);
|
||||
|
@ -95,7 +95,7 @@ public class CatalogController {
|
|||
|
||||
@PostMapping("/catalog_editor/add_time")
|
||||
public String add_time(@RequestParam int minimumTimePeriod,
|
||||
@RequestParam CustomCatalogEntry.EventType eventType,
|
||||
@RequestParam OrderType eventType,
|
||||
@RequestParam Map<String, Integer> products,
|
||||
Model model) {
|
||||
formCatalogEntry.setMinimumTimePeriod(minimumTimePeriod);
|
||||
|
@ -107,19 +107,19 @@ public class CatalogController {
|
|||
public String chooseEvent(String events) {
|
||||
switch (events) {
|
||||
case "event_catering":
|
||||
formCatalogEntry.setEventType(CustomCatalogEntry.EventType.EVENT_CATERING);
|
||||
formCatalogEntry.setEventType(OrderType.EVENT_CATERING);
|
||||
break;
|
||||
case "party_service":
|
||||
formCatalogEntry.setEventType(CustomCatalogEntry.EventType.PARTY_SERVICE);
|
||||
case "sushi_night":
|
||||
formCatalogEntry.setEventType(OrderType.SUSHI_NIGHT);
|
||||
break;
|
||||
case "mobile_breakfast":
|
||||
formCatalogEntry.setEventType(CustomCatalogEntry.EventType.MOBILE_BREAKFAST);
|
||||
formCatalogEntry.setEventType(OrderType.MOBILE_BREAKFAST);
|
||||
break;
|
||||
case "rent_a_cook":
|
||||
formCatalogEntry.setEventType(CustomCatalogEntry.EventType.RENT_A_COOK);
|
||||
formCatalogEntry.setEventType(OrderType.RENT_A_COOK);
|
||||
break;
|
||||
default:
|
||||
formCatalogEntry.setEventType(CustomCatalogEntry.EventType.EVENT_CATERING);
|
||||
formCatalogEntry.setEventType(OrderType.EVENT_CATERING);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import catering.order.OrderType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CustomCatalogEntry {
|
||||
static int idCounter = 0;
|
||||
private int id;
|
||||
private EventType eventType;
|
||||
private OrderType eventType;
|
||||
private Map<String, Integer> products;
|
||||
private int minimumTimePeriod; // Declared as int for simplification of the prototype. Only whole hours.
|
||||
private int totalCost; // Should actually accumulate the price of all items.
|
||||
|
||||
public CustomCatalogEntry(EventType eventType, Map<String, Integer> products, int minimumTimePeriod, int totalCost) {
|
||||
public CustomCatalogEntry(OrderType eventType, Map<String, Integer> products, int minimumTimePeriod, int totalCost) {
|
||||
this.id = idCounter;
|
||||
idCounter++;
|
||||
this.eventType = eventType;
|
||||
|
@ -23,7 +25,7 @@ public class CustomCatalogEntry {
|
|||
return id;
|
||||
}
|
||||
|
||||
public EventType getEventType() {
|
||||
public OrderType getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
|
@ -39,7 +41,7 @@ public class CustomCatalogEntry {
|
|||
return totalCost;
|
||||
}
|
||||
|
||||
public void setEventType(EventType eventType) {
|
||||
public void setEventType(OrderType eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
|
@ -57,11 +59,4 @@ public class CustomCatalogEntry {
|
|||
public void setTotalCost(int totalCost) {
|
||||
this.totalCost = totalCost;
|
||||
}
|
||||
|
||||
public enum EventType {
|
||||
EVENT_CATERING,
|
||||
PARTY_SERVICE,
|
||||
MOBILE_BREAKFAST,
|
||||
RENT_A_COOK
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import catering.order.OrderType;
|
||||
import org.salespointframework.core.DataInitializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -20,7 +21,7 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer {
|
|||
Map<String, Integer> products = new HashMap<>();
|
||||
products.put("Brötchen", 30);
|
||||
products.put("Kerze", 20);
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(CustomCatalogEntry.EventType.EVENT_CATERING, products, 4, 500));
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(OrderType.EVENT_CATERING, products, 4, 500));
|
||||
|
||||
products = new HashMap<>();
|
||||
products.put("Kuchen", 3);
|
||||
|
@ -28,6 +29,6 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer {
|
|||
products.put("Pizza Margherita", 1);
|
||||
products.put("Pizza Quattro Formaggi", 1);
|
||||
products.put("Ballon", 20);
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(CustomCatalogEntry.EventType.PARTY_SERVICE, products, 2, 1000));
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(OrderType.RENT_A_COOK, products, 2, 1000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<form th:object="${formCatalogEntry}" method="post" th:action="@{/catalog_editor/chooseEvent}">
|
||||
<select class="form-select w-auto d-inline-block" name="events" id="events">
|
||||
<option value="event_catering">Eventcatering</option>
|
||||
<option value="party_service">Partyservice</option>
|
||||
<option value="sushi_night">Sushi Night</option>
|
||||
<option value="mobile_breakfast">Mobile Breakfast</option>
|
||||
<option value="rent_a_cook">Rent-a-Cook</option>
|
||||
</select>
|
||||
|
|
Loading…
Reference in a new issue