Class UserService
java.lang.Object
ntnu.idatt2016.v233.SmartMat.service.user.UserService
UserService is a class that implements the UserDetailsService interface.
- Version:
- 1.1
- Author:
- Birk, Stian
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String>
addAllergyToUser
(String username, String allergyName) Adds allergy to uservoid
addFavoriteRecipe
(String username, long recipeId) adds recipe to users favorite recipesvoid
deletes user from databasegetPassword
(String userName) gets password from usergetUserFromEmail
(String email) gets user from email out of databasegetUserFromUsername
(String username) gets user from username out of databasegetUsers()
Gets all users from the databaseorg.springframework.http.ResponseEntity<String>
removeAllergyFromUser
(String username, String allergyName) Removes allergy from usersaves user to databasesaves list of users to databaseupdateUser
(User user) update user if it already exists cant update username from this
-
Constructor Details
-
UserService
public UserService()
-
-
Method Details
-
getUserFromUsername
gets user from username out of database- Parameters:
username
- username of user- Returns:
- user
-
getUsers
Gets all users from the database -
updateUser
update user if it already exists cant update username from this- Parameters:
user
- user to update- Returns:
- optional with user if succeded else return null
-
getPassword
gets password from user- Parameters:
userName
- username of user- Returns:
- password of user
-
saveUser
saves user to database- Parameters:
user
- user to save- Returns:
- saved user
-
saveUsers
saves list of users to database- Parameters:
users
- list of users to save- Returns:
- list of saved users
-
delete
deletes user from database- Parameters:
user
- user to delete
-
getUserFromEmail
gets user from email out of database- Parameters:
email
- email of user- Returns:
- user
-
addFavoriteRecipe
adds recipe to users favorite recipes- Parameters:
username
- username of userrecipeId
- id of recipe- Throws:
RuntimeException
- if user or recipe does not exist or user
-
addAllergyToUser
public org.springframework.http.ResponseEntity<String> addAllergyToUser(String username, String allergyName) Adds allergy to user- Parameters:
username
- username of userallergyName
- name of allergy- Returns:
- string of allergies
-
removeAllergyFromUser
public org.springframework.http.ResponseEntity<String> removeAllergyFromUser(String username, String allergyName) Removes allergy from user- Parameters:
username
- username of userallergyName
- name of allergy- Returns:
- user with removed allergy
-