mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
parent
2515c17de5
commit
58dae6532e
|
@ -19,6 +19,7 @@ package catering.inventory;
|
||||||
import org.salespointframework.catalog.Product;
|
import org.salespointframework.catalog.Product;
|
||||||
import org.salespointframework.inventory.UniqueInventory;
|
import org.salespointframework.inventory.UniqueInventory;
|
||||||
import org.salespointframework.inventory.UniqueInventoryItem;
|
import org.salespointframework.inventory.UniqueInventoryItem;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
@ -43,6 +44,7 @@ class InventoryController {
|
||||||
this.cateringCatalog = cateringCatalog;
|
this.cateringCatalog = cateringCatalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
@GetMapping("/inventory")
|
@GetMapping("/inventory")
|
||||||
String list(Model model) {
|
String list(Model model) {
|
||||||
model.addAttribute("inventory", inventory.findAll());
|
model.addAttribute("inventory", inventory.findAll());
|
||||||
|
@ -50,6 +52,7 @@ class InventoryController {
|
||||||
return "inventory";
|
return "inventory";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
@GetMapping("/inventory/edit/{pid}")
|
@GetMapping("/inventory/edit/{pid}")
|
||||||
String edit(Model model, @PathVariable Product pid) {
|
String edit(Model model, @PathVariable Product pid) {
|
||||||
model.addAttribute("product", pid);
|
model.addAttribute("product", pid);
|
||||||
|
@ -58,6 +61,7 @@ class InventoryController {
|
||||||
return "inventory-mutate";
|
return "inventory-mutate";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
@PostMapping("/inventory/edit/{pid}")
|
@PostMapping("/inventory/edit/{pid}")
|
||||||
String edit(@Valid InventoryMutateForm form, Errors result, @PathVariable Product pid) {
|
String edit(@Valid InventoryMutateForm form, Errors result, @PathVariable Product pid) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
@ -80,11 +84,13 @@ class InventoryController {
|
||||||
return "redirect:/inventory";
|
return "redirect:/inventory";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
@GetMapping("/inventory/add")
|
@GetMapping("/inventory/add")
|
||||||
String add() {
|
String add() {
|
||||||
return "inventory-mutate";
|
return "inventory-mutate";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
@PostMapping("/inventory/add")
|
@PostMapping("/inventory/add")
|
||||||
String add(@Valid InventoryMutateForm form, Errors result) {
|
String add(@Valid InventoryMutateForm form, Errors result) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
@ -97,6 +103,7 @@ class InventoryController {
|
||||||
return "redirect:/inventory";
|
return "redirect:/inventory";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
@GetMapping("/inventory/delete/{pid}")
|
@GetMapping("/inventory/delete/{pid}")
|
||||||
String delete(@PathVariable Product pid) {
|
String delete(@PathVariable Product pid) {
|
||||||
UniqueInventoryItem item = inventory.findByProduct(pid).get();
|
UniqueInventoryItem item = inventory.findByProduct(pid).get();
|
||||||
|
|
Loading…
Reference in a new issue