mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Initialize all Catalog classes regarding the prototype
This commit is contained in:
parent
6d8b8bd5ca
commit
9747fc5589
25
src/main/java/catering/orderCatalog/CatalogController.java
Normal file
25
src/main/java/catering/orderCatalog/CatalogController.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Controller
|
||||
public class CatalogController {
|
||||
|
||||
@GetMapping("/catalog")
|
||||
public String catalog() {
|
||||
return "catalog";
|
||||
}
|
||||
|
||||
@GetMapping("/catalog_editor")
|
||||
public String event_configuration() {
|
||||
return "catalog_editor";
|
||||
}
|
||||
|
||||
@PostMapping("/catalog/remove")
|
||||
public String removeItem() {
|
||||
return "redirect:/catalog";
|
||||
}
|
||||
|
||||
}
|
42
src/main/java/catering/orderCatalog/CustomCatalogEntry.java
Normal file
42
src/main/java/catering/orderCatalog/CustomCatalogEntry.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CustomCatalogEntry {
|
||||
static int idCounter = 0;
|
||||
private int id;
|
||||
private EventType eventType;
|
||||
private Map<String, Integer> products;
|
||||
private int minimumTimePeriod; // Declared as int for simplification of the prototype. Only whole hours.
|
||||
|
||||
public CustomCatalogEntry(EventType eventType, Map<String, Integer> products, int minimumTimePeriod) {
|
||||
this.id = idCounter;
|
||||
idCounter++;
|
||||
this.eventType = eventType;
|
||||
this.products = products;
|
||||
this.minimumTimePeriod = minimumTimePeriod;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public EventType getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getProducts() {
|
||||
return products;
|
||||
}
|
||||
|
||||
public int getMinimumTimePeriod() {
|
||||
return minimumTimePeriod;
|
||||
}
|
||||
|
||||
public enum EventType {
|
||||
EVENT_CATERING,
|
||||
PARTY_SERVICE,
|
||||
MOBILE_BREAKFAST,
|
||||
RENT_A_COOK
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import org.salespointframework.core.DataInitializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class CustomCatalogEntryDataInitializer implements DataInitializer {
|
||||
private CustomCatalogEntryRepository catalogEntryRepository;
|
||||
|
||||
public CustomCatalogEntryDataInitializer(CustomCatalogEntryRepository catalogEntryRepository) {
|
||||
this.catalogEntryRepository = catalogEntryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
System.out.println("Initialize CatalogEntryRepository");
|
||||
|
||||
Map<String, Integer> products = new HashMap<>();
|
||||
products.put("Brötchen", 30);
|
||||
products.put("Kerze", 20);
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(
|
||||
CustomCatalogEntry.EventType.EVENT_CATERING,
|
||||
products,
|
||||
3
|
||||
));
|
||||
|
||||
products = new HashMap<>();
|
||||
products.put("Kuchen", 3);
|
||||
products.put("Pizza Funghi", 1);
|
||||
products.put("Pizza Margherita", 1);
|
||||
products.put("Pizza Quattro Formaggi", 1);
|
||||
products.put("Ballon", 20);
|
||||
catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(
|
||||
CustomCatalogEntry.EventType.PARTY_SERVICE,
|
||||
products,
|
||||
3
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package catering.orderCatalog;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class CustomCatalogEntryRepository {
|
||||
private Set<CustomCatalogEntry> catalogEntries;
|
||||
|
||||
public CustomCatalogEntryRepository() {
|
||||
this.catalogEntries = new HashSet<>();
|
||||
}
|
||||
|
||||
public boolean addCatalogEntry(CustomCatalogEntry catalogEntry) {
|
||||
return catalogEntries.add(catalogEntry);
|
||||
}
|
||||
|
||||
public boolean removeOrder(int catalogEntryID) {
|
||||
for (CustomCatalogEntry catalogEntry : catalogEntries) {
|
||||
if (catalogEntry.getId() == catalogEntryID) {
|
||||
return this.catalogEntries.remove(catalogEntry);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -25,10 +25,4 @@ public class WelcomeController {
|
|||
public String index() {
|
||||
return "welcome";
|
||||
}
|
||||
|
||||
@GetMapping("/catalog")
|
||||
public String catalog() {
|
||||
return "catalog";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<h1>Katalog</h1>
|
||||
<h1>Katalog</h1>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
@ -62,6 +62,12 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form th:action="@{/catalog_editor}">
|
||||
<button type="submit">Hinzufügen</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="button">Hinzufügen</button>
|
||||
</div>
|
||||
|
|
76
src/main/resources/templates/catalog_editor.html
Normal file
76
src/main/resources/templates/catalog_editor.html
Normal file
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<title>Auftragskonfiguration</title></head>
|
||||
<body>
|
||||
<nav>
|
||||
<div class="topnav"> <!-- später für css -->
|
||||
<a th:href="@{/}" th:text="Home">Home</a>
|
||||
<a th:href="@{/catalog}" th:text="Katalog">Katalog</a>
|
||||
<a th:href="@{/event}" th:text="Eventplaner">Eventplaner</a>
|
||||
<a th:href="@{/orders}" th:text="Aufträge">Aufträge</a>
|
||||
<!--<a href="#account">Mein Konto</a>-->
|
||||
</div>
|
||||
</nav>
|
||||
<h1>Auftrag konfigurieren</h1>
|
||||
<div class="content">
|
||||
<h2>Dienstleistung</h2>
|
||||
<label for="dienstleistungen"></label>
|
||||
<select name="dienstleistungen" id="dienstleistungen">
|
||||
<option value="eventcatering">Eventcatering</option>
|
||||
<option value="partyservice">Partyservice</option>
|
||||
<option value="mobile_breakfast">Mobile Breakfast</option>
|
||||
<option value="rent-a-cook">Rent-a-Cook</option>
|
||||
</select>
|
||||
Eventbasispreis: 500€
|
||||
|
||||
<h2>Mindestzeitraum</h2>
|
||||
<label>Mindestzeitraum:
|
||||
<input type="number" name="amount" min="1" step="1" value="1"/>
|
||||
</label>h
|
||||
|
||||
<h2>Basisausstattung</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Produktname</th>
|
||||
<th>Menge</th>
|
||||
<th>Stückpreis</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Brötchen</td>
|
||||
<td>
|
||||
<input type="number" name="amount" min="1" step="1" value="1"/>
|
||||
</td>
|
||||
<td>1,00 €</td>
|
||||
<td>
|
||||
<form method="post" th:action="@{/catalog/remove}">
|
||||
<input type="hidden" name="itemID" value="0"/>
|
||||
<input type="submit" value="remove" th:value="Entfernen"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kerze</td>
|
||||
<td>
|
||||
<input type="number" name="amount" min="1" step="1" value="1"/>
|
||||
</td>
|
||||
<td>3.00 €</td>
|
||||
<td>
|
||||
<form method="post" th:action="@{/catalog/remove}">
|
||||
<input type="hidden" name="itemID" value="0"/>
|
||||
<input type="submit" value="remove" th:value="Entfernen"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[Artikel Hinzufügen]</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
Gesamtpreis: 90 €<br>
|
||||
<button>Zum Katalog hinzufügen</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,52 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<title>Auftragskonfiguration</title></head>
|
||||
<body>
|
||||
<nav>
|
||||
<a href="/dienstleistungen.html/">Dienstleistungen</a> |
|
||||
<button>Login</button>
|
||||
</nav>
|
||||
<h1>Auftrag konfigurieren</h1>
|
||||
<div class="content">
|
||||
<h2>Dienstleistung</h2>
|
||||
<label for="dienstleistungen"></label>
|
||||
<select name="dienstleistungen" id="dienstleistungen">
|
||||
<option value="eventcatering">Eventcatering</option>
|
||||
<option value="partyservice">Partyservice</option>
|
||||
<option value="mobile_breakfast">Mobile Breakfast</option>
|
||||
<option value="rent-a-cook">Rent-a-Cook</option>
|
||||
</select>
|
||||
Preis 30€
|
||||
|
||||
<h2>Artikel</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Produktname</th>
|
||||
<th>Menge</th>
|
||||
<th>Stückzahl</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Brötchen</td>
|
||||
<td>30 [ + / - ]</td>
|
||||
<td>1,00 €</td>
|
||||
<td>[Löschen]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kerze</td>
|
||||
<td>20 [ + / - ]</td>
|
||||
<td>3.00 €</td>
|
||||
<td>[Löschen]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[Artikel Hinzufügen]</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
Gesamtpreis: 90 €<br>
|
||||
<button>In den Warenkorb</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue