Package com.plannaplan.services
Class UserService
java.lang.Object
com.plannaplan.services.UserService
@Service
public class UserService
extends java.lang.Object
Service of UserService which can get(By Email), login, save user.
-
Constructor Summary
Constructors Constructor Description UserService()
-
Method Summary
Modifier and Type Method Description boolean
adminExists()
User
checkForUser(java.lang.String email, java.lang.String usosId)
checks if user exist and return him or creates new one with student role otherwiseUser
checkForUser(java.lang.String email, java.lang.String usosId, UserRoles roleIfNotExist)
checks if user exist and creates new one if doesn'tjava.util.List<User>
getAllStudents()
java.util.Optional<User>
getByAuthority(java.lang.String authority)
return user by given authorityjava.util.Optional<User>
getById(java.lang.Long userId)
java.util.Optional<User>
getByToken(java.lang.String token)
java.util.List<User>
getStudentsSortedByRanking()
get students sorted by their rankingUser
getUserByEmail(java.lang.String email)
java.util.Optional<User>
getUserByRefreshToken(java.lang.String refreshToken)
User
login(User authority)
generates token for user and if user don't have name in database it will attemp to obtain these from usos api and saves changes in databaseUser
save(User user)
sacves user to databse and return instatnce with idvoid
saveAll(java.util.List<User> users)
java.util.List<User>
searchForStudents(java.lang.String query)
search for user with given query
-
Constructor Details
-
UserService
public UserService()
-
-
Method Details
-
checkForUser
checks if user exist and return him or creates new one with student role otherwise- Parameters:
email
- user email in usosusosId
- user id in usos- Returns:
- user entity instace containing changes saved in database
-
checkForUser
public User checkForUser(java.lang.String email, java.lang.String usosId, UserRoles roleIfNotExist)checks if user exist and creates new one if doesn't- Parameters:
email
- user email in usosusosId
- user id in usosroleIfNotExist
- role to be set in case user is not in database yet- Returns:
- user entity instace containing changes saved in database
-
login
generates token for user and if user don't have name in database it will attemp to obtain these from usos api and saves changes in database- Parameters:
authority
- user we want to login- Returns:
- user with changed values after save in db
- Throws:
UserNotFoundException
- throwed if user doesn't exist
-
save
sacves user to databse and return instatnce with id- Parameters:
user
- to be saved- Returns:
- instatnce with bd id
-
getUserByEmail
- Parameters:
email
- of user to be find- Returns:
- user with given mail
- Throws:
UserNotFoundException
- throwed if user doesn't exist
-
getByAuthority
return user by given authority- Parameters:
authority
- user usosId or email- Returns:
- optional with user if found
-
getByToken
-
searchForStudents
search for user with given query- Parameters:
query
- string that will be matched to users name and surname- Returns:
- list opf results
-
getById
-
getAllStudents
-
getUserByRefreshToken
-
adminExists
public boolean adminExists() -
saveAll
-
getStudentsSortedByRanking
get students sorted by their ranking- Returns:
- list of students
-