mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add display of all catalog entries (CustomCatalogEntry) in catalog
This commit is contained in:
parent
34f4fcf069
commit
f1f71beaf4
|
@ -3,12 +3,19 @@ package catering.orderCatalog;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
@Controller
|
||||
public class CatalogController {
|
||||
private CustomCatalogEntryRepository catalogEntryRepository;
|
||||
|
||||
public CatalogController(CustomCatalogEntryRepository catalogEntryRepository) {
|
||||
this.catalogEntryRepository = catalogEntryRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/catalog")
|
||||
public String catalog() {
|
||||
public String catalog(Model model) {
|
||||
model.addAttribute("catalogEntries", catalogEntryRepository.getCatalogEntries());
|
||||
return "catalog";
|
||||
}
|
||||
|
||||
|
@ -19,7 +26,7 @@ public class CatalogController {
|
|||
|
||||
@PostMapping("/catalog/remove")
|
||||
public String removeItem() {
|
||||
return "redirect:/catalog";
|
||||
return "catalog_editor";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,13 +8,15 @@ public class CustomCatalogEntry {
|
|||
private EventType 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) {
|
||||
public CustomCatalogEntry(EventType eventType, Map<String, Integer> products, int minimumTimePeriod, int totalCost) {
|
||||
this.id = idCounter;
|
||||
idCounter++;
|
||||
this.eventType = eventType;
|
||||
this.products = products;
|
||||
this.minimumTimePeriod = minimumTimePeriod;
|
||||
this.totalCost = totalCost;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -29,8 +31,12 @@ public class CustomCatalogEntry {
|
|||
return products;
|
||||
}
|
||||
|
||||
public int getMinimumTimePeriod() {
|
||||
return minimumTimePeriod;
|
||||
public String getMinimumTimePeriod() {
|
||||
return minimumTimePeriod + " h";
|
||||
}
|
||||
|
||||
public String getTotalCost() {
|
||||
return totalCost + " €";
|
||||
}
|
||||
|
||||
public enum EventType {
|
||||
|
|
|
@ -23,7 +23,8 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer {
|
|||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(
|
||||
CustomCatalogEntry.EventType.EVENT_CATERING,
|
||||
products,
|
||||
3
|
||||
3,
|
||||
300
|
||||
));
|
||||
|
||||
products = new HashMap<>();
|
||||
|
@ -35,7 +36,8 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer {
|
|||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(
|
||||
CustomCatalogEntry.EventType.PARTY_SERVICE,
|
||||
products,
|
||||
3
|
||||
3,
|
||||
500
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,4 +25,8 @@ public class CustomCatalogEntryRepository {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<CustomCatalogEntry> getCatalogEntries() {
|
||||
return catalogEntries;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,35 +29,18 @@
|
|||
<th>Basisausstattung</th>
|
||||
<th>Preis ab</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr th:each="catalogEntry : ${catalogEntries}">
|
||||
<td>
|
||||
**BILD**
|
||||
</td>
|
||||
<td>Rent-a-Cook</td>
|
||||
<td>3h</td>
|
||||
<td th:text="${catalogEntry.getEventType()}">
|
||||
<td th:text="${catalogEntry.getMinimumTimePeriod()}">h
|
||||
<td>
|
||||
<ul>
|
||||
<li>1 Koch</li>
|
||||
<li>300kg Mettbrötchen</li>
|
||||
<li>300kg vegane Weißwurst</li>
|
||||
<ul th:each="product : ${catalogEntry.getProducts()}">
|
||||
<li th:text="${product}"/>
|
||||
</ul>
|
||||
</td>
|
||||
<td>499,99€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
**BILD**
|
||||
</td>
|
||||
<td>Sushi-Abend</td>
|
||||
<td>4h</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>2 Köche</li>
|
||||
<li>300kg Sushi</li>
|
||||
<li>300kg Sushi vegan</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>699,99€</td>
|
||||
<td th:text="${catalogEntry.getTotalCost()}">
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -68,6 +51,12 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form th:action="@{/catalog_editor}">
|
||||
<button type="submit">Hinzufügen</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="button">Hinzufügen</button>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<title>Auftragskonfiguration</title></head>
|
||||
<title>Basiseventkonfiguration</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<div class="topnav"> <!-- später für css -->
|
||||
|
@ -14,7 +15,7 @@
|
|||
<!--<a href="#account">Mein Konto</a>-->
|
||||
</div>
|
||||
</nav>
|
||||
<h1>Auftrag konfigurieren</h1>
|
||||
<h1>Basisevent konfigurieren</h1>
|
||||
<div class="content">
|
||||
<h2>Dienstleistung</h2>
|
||||
<label for="dienstleistungen"></label>
|
||||
|
|
Loading…
Reference in a new issue