Package balu.pizza.webapp.services
Class PizzaService
java.lang.Object
balu.pizza.webapp.services.PizzaService
Pizza service
-
Constructor Summary
ConstructorDescriptionPizzaService
(PizzaRepository pizzaRepository, IngredientService ingredientService) Implementing dependencies -
Method Summary
Modifier and TypeMethodDescriptionsaves new pizza to DBfindAll()
Searches all pizzasfindAllSortedBy
(String param) Searches all pizza in DBfindByCafe
(Cafe cafe) Searches of all pizzas associated with the cafefindById
(int id) Searches pizza by idfindByName
(String name) Searches pizza by namefindByPerson
(Person person) Searches all pizzas associated with the userfindByPizzaSize
(String size) Searches all pizzas by base sizedouble
getCalculatedPrice
(Pizza pizza) The method calculates the cost of pizza the size of the pizza and all of its ingredients are taken into accountvoid
setNewPrice
(Pizza pizza, double newPrice) Method for changing the price of a pizzaMethod for updating pizza fields with data from a form
-
Constructor Details
-
PizzaService
@Autowired public PizzaService(PizzaRepository pizzaRepository, IngredientService ingredientService) Implementing dependencies- Parameters:
pizzaRepository
- Pizza RepositoryingredientService
- Ingredient Service
-
-
Method Details
-
findAll
Searches all pizzas- Returns:
- Sorted by name list of all pizzas from DB
-
findByPizzaSize
Searches all pizzas by base size- Parameters:
size
- Base size- Returns:
- Sorted by name list of all pizzas with size 'size'
-
findById
Searches pizza by id- Parameters:
id
-- Returns:
- if successful: Pizza
- Throws:
NotFoundException
- if pizza was not found
-
getCalculatedPrice
The method calculates the cost of pizza the size of the pizza and all of its ingredients are taken into account- Parameters:
pizza
-- Returns:
- Calculated price
-
setNewPrice
Method for changing the price of a pizza- Parameters:
pizza
- PizzanewPrice
- new Price
-
create
saves new pizza to DB- Parameters:
pizza
-- Returns:
- saved pizza
-
findByName
Searches pizza by name- Parameters:
name
- pizza name- Returns:
- An object that may contain a Pizza or be empty
-
findByPerson
Searches all pizzas associated with the user- Parameters:
person
- Entity Person- Returns:
- list of all pizzas associated with the user
-
findAllSortedBy
Searches all pizza in DB- Parameters:
param
- Pizza sorting parameter- Returns:
- Sorted by param list of all pizzas from BD
-
update
Method for updating pizza fields with data from a form- Parameters:
pizzaData
- Data from form- Returns:
- updated Pizza
-
findByCafe
Searches of all pizzas associated with the cafe- Parameters:
cafe
- Entity Cafe- Returns:
- List of all pizzas associated with the cafe
-