Class PizzaController

java.lang.Object
balu.pizza.webapp.controllers.PizzaController

@Controller @RequestMapping("/pizza") public class PizzaController extends Object
Pizza controller
  • Constructor Details

    • PizzaController

      @Autowired public PizzaController(PizzaService pizzaService, PersonService personService, CafeService cafeService, UserUtil userUtil, IngredientService ingredientService)
      Parameters:
      pizzaService - Pizzas service
      personService - Persons service
      cafeService - Cafes service
      userUtil - Set users utils
      ingredientService - 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

      admin panel

      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 ID
      pizzaId - Pizza ID
      model -
      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 ID
      pizzaId - Pizza ID
      model -
      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 ID
      model -
      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

      admin panel

      Parameters:
      pizzaId - Pizza ID
      model -
      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 only

      The method calculates and displays the cost of the pizza, taking into account its ingredients and size

      admin panel

      Parameters:
      pizzaId - Pizza ID
      model -
      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 ID
      price - New price
      Returns: