mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
fixup! Update basics of order package to salespoint
This commit is contained in:
parent
506824a8b7
commit
43785cde3d
|
@ -8,6 +8,7 @@ import org.salespointframework.order.Order;
|
|||
import org.salespointframework.order.OrderManagement;
|
||||
import org.salespointframework.quantity.Quantity;
|
||||
import org.salespointframework.time.Interval;
|
||||
import org.salespointframework.useraccount.Role;
|
||||
import org.salespointframework.useraccount.UserAccount;
|
||||
import org.salespointframework.useraccount.web.LoggedIn;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -92,12 +93,16 @@ public class OrderController {
|
|||
}
|
||||
|
||||
@PostMapping("/allOrders/remove")
|
||||
@PreAuthorize("hasRole('BOSS')")
|
||||
public String removeOrder(@RequestParam Order.OrderIdentifier orderID) {
|
||||
CustomOrder myOrder = orderManagement.get(orderID).get(); // TODO
|
||||
public String removeOrder(@RequestParam Order.OrderIdentifier orderID, @LoggedIn Optional<UserAccount> userAccount) {
|
||||
return userAccount.map(account -> {
|
||||
if (account.hasRole(Role.of("ADMIN"))) {
|
||||
CustomOrder myOrder = orderManagement.get(orderID).get(); // FIXME
|
||||
orderManagement.cancelOrder(myOrder, "I have my own reasons.");
|
||||
return "redirect:/allOrders";
|
||||
}
|
||||
return "redirect:/";
|
||||
}).orElse("redirect:/");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/event/addProduct")
|
||||
|
@ -114,7 +119,6 @@ public class OrderController {
|
|||
return userAccount.map(account -> {
|
||||
CustomOrder myOrder = new CustomOrder(account.getId(), cart);
|
||||
orderManagement.payOrder(myOrder); // TODO: change this later
|
||||
orderManagement.completeOrder(myOrder); // TODO: change this later
|
||||
cart.clear();
|
||||
|
||||
List<CustomOrder> myOrders = orderManagement.findBy(account).stream().collect(Collectors.toList());
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<th>Kunde</th>
|
||||
<th>Produktdetails</th>
|
||||
<th>Rechnung</th>
|
||||
<th>Bezahlt</th>
|
||||
<th>Status</th>
|
||||
<th>Preis</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<span>Keine Rechnung verfügbar</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>☒</td> <!--von Admin bearbeitbar-->
|
||||
<td th:text="${order.getOrderStatus()}"></td> <!--von Admin bearbeitbar-->
|
||||
<td>
|
||||
<th:block th:text="${order.getTotal()}"/>
|
||||
<th:block th:text="€"/>
|
||||
|
|
Loading…
Reference in a new issue