Package balu.pizza.webapp.controllers
Class PizzaController
java.lang.Object
balu.pizza.webapp.controllers.PizzaController
Pizza controller
-
Constructor Summary
ConstructorDescriptionPizzaController
(PizzaService pizzaService, PersonService personService, CafeService cafeService, UserUtil userUtil, IngredientService ingredientService) -
Method Summary
Modifier and TypeMethodDescriptionaddPizzaToCafeMenu
(int cafeId, org.springframework.ui.Model model) Cafe menu editing page Admin onlyaddPizzaToPersonFav
(int pizzaId, org.springframework.ui.Model model) The method adds the selected pizza to favorites list active usercheckPricePage
(int pizzaId, org.springframework.ui.Model model, Price price) Control and edit pizza price page Admin onlydeletePizzaFromMenu
(int cafeId, int pizzaId, org.springframework.ui.Model model) The method deleting the selected pizza from the cafe menupizzaPage
(int pizzaId, org.springframework.ui.Model model) Page for displaying detailed pizza informationremoveFromPersonFav
(int pizzaId) The method deleting the selected pizza from favorites list active usersetNewPrice
(int pizzaId, @Valid Price price) The method updates the pizza price in the databaseupdateMenu
(int cafeId, int pizzaId, org.springframework.ui.Model model) The method adds the selected pizza to the cafe menu
-
Constructor Details
-
PizzaController
@Autowired public PizzaController(PizzaService pizzaService, PersonService personService, CafeService cafeService, UserUtil userUtil, IngredientService ingredientService) - Parameters:
pizzaService
- Pizzas servicepersonService
- Persons servicecafeService
- Cafes serviceuserUtil
- Set users utilsingredientService
- Ingredient service
-
-
Method Details
-
addPizzaToCafeMenu
@PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/add_to_cafe/{id}") public String addPizzaToCafeMenu(@PathVariable("id") int cafeId, org.springframework.ui.Model model) Cafe menu editing page Admin only- Parameters:
cafeId
-model
-- Returns:
- Generates a page for menu editing
-
updateMenu
@PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/add_to_menu/{cafe}/{pizza}") public String updateMenu(@PathVariable("cafe") int cafeId, @PathVariable("pizza") int pizzaId, org.springframework.ui.Model model) The method adds the selected pizza to the cafe menu- Parameters:
cafeId
- Cafe IDpizzaId
- Pizza IDmodel
-- Returns:
- if successful - redirects to the cafe page
-
deletePizzaFromMenu
@GetMapping("/del_from_menu/{cafe}/{pizza}") public String deletePizzaFromMenu(@PathVariable("cafe") int cafeId, @PathVariable("pizza") int pizzaId, org.springframework.ui.Model model) The method deleting the selected pizza from the cafe menu- Parameters:
cafeId
- Cafe IDpizzaId
- Pizza IDmodel
-- Returns:
- if successful - redirects to the cafe page
-
addPizzaToPersonFav
@GetMapping("/addToFav/{Id}") public String addPizzaToPersonFav(@PathVariable("Id") int pizzaId, org.springframework.ui.Model model) The method adds the selected pizza to favorites list active user- Parameters:
pizzaId
- Pizza IDmodel
-- Returns:
- if successful - redirects to the menu page
-
removeFromPersonFav
@GetMapping("/removeFromFav/{id}") public String removeFromPersonFav(@PathVariable("id") int pizzaId) The method deleting the selected pizza from favorites list active user- Parameters:
pizzaId
- Pizza ID- Returns:
- if successful - redirects to the menu page
-
pizzaPage
@GetMapping("/{id}") public String pizzaPage(@PathVariable("id") int pizzaId, org.springframework.ui.Model model) Page for displaying detailed pizza information- Parameters:
pizzaId
- Pizza IDmodel
-- Returns:
-
checkPricePage
@PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/checkPrice/{id}") public String checkPricePage(@PathVariable("id") int pizzaId, org.springframework.ui.Model model, @ModelAttribute("price") Price price) Control and edit pizza price page Admin onlyThe method calculates and displays the cost of the pizza, taking into account its ingredients and size
- Parameters:
pizzaId
- Pizza IDmodel
-price
- Price- Returns:
-
setNewPrice
@PreAuthorize("hasRole(\'ADMIN\')") @PostMapping("/setPrice/{id}") public String setNewPrice(@PathVariable("id") int pizzaId, @ModelAttribute("price") @Valid @Valid Price price) The method updates the pizza price in the database- Parameters:
pizzaId
- Pizza IDprice
- New price- Returns:
-