Package balu.pizza.webapp.services
Class PersonService
java.lang.Object
balu.pizza.webapp.services.PersonService
Person Service
-
Constructor Summary
ConstructorsConstructorDescriptionPersonService(PersonRepository personRepository, PizzaRepository pizzaRepository, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) Implementing repositories -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPizzaToFav(Person person, Pizza pizza) Method of adding a pizza to the user's favorites listfindAll()Searches all usersfindOne(int personId) Searches user by IDfindUserByEmail(String email) The method of searching for a User by emailfindUserByUsername(String username) The method of searching for a User by usernameThe method of creating and saving in DB new UservoidremovePizzaFromFav(Person person, Pizza pizza) Method of removinf a pizza from the user's favorites listvoidSaving user on DBThe method of updating in DB new User
-
Constructor Details
-
PersonService
@Autowired public PersonService(PersonRepository personRepository, PizzaRepository pizzaRepository, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder) Implementing repositories- Parameters:
personRepository- Person RepositorypizzaRepository- Pizza RepositorypasswordEncoder- Password encryption bin
-
-
Method Details
-
findUserByUsername
The method of searching for a User by username- Parameters:
username- Username- Returns:
- An object that may contain a User or be empty
-
findUserByEmail
The method of searching for a User by email- Parameters:
email- Email- Returns:
- An object that may contain a User or be empty
-
register
The method of creating and saving in DB new User- Parameters:
person-- Returns:
- created User
-
update
The method of updating in DB new User- Parameters:
person- Entity PersonformPerson- Form data with fields- Returns:
- Updated User
-
findAll
Searches all users- Returns:
- List of all users from DB
-
addPizzaToFav
Method of adding a pizza to the user's favorites list- Parameters:
person- Entity Personpizza- Entity pizza
-
removePizzaFromFav
Method of removinf a pizza from the user's favorites list- Parameters:
person- Entity Personpizza- Entity Pizza
-
save
Saving user on DB- Parameters:
person-
-
findOne
Searches user by ID- Parameters:
personId- user ID- Returns:
- if successful: User
- Throws:
NotFoundException- If the user was not found
-