Klasse UserService
java.lang.Object
com.spaghetticodegang.trylater.user.UserService
- Alle implementierten Schnittstellen:
org.springframework.security.core.userdetails.UserDetailsService
@Service
public class UserService
extends Object
implements org.springframework.security.core.userdetails.UserDetailsService
Service layer for handling user-related business logic.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungcreateUserMeResponseDto
(User user) Creates a detailed user DTO from aUser
entity, including sensitive fields like email.createUserResponseDto
(User user) Creates a public-facing user DTO from aUser
entity.void
deleteUserProfile
(User me, UserMeDeleteDto userMeDeleteDto) Deletes a user profile and manages the handling for deleting the contacts and assignments for that user.findUserById
(Long userId) Finds a user by their unique ID.org.springframework.security.core.userdetails.UserDetails
loadUserByUsername
(String input) Loads a user by username or email for authentication.registerUser
(UserMeRegistrationDto userMeRegistrationDto) Registers a new user if the provided email and username are not already in use.searchUser
(String username) searches for user by their userName or emailupdateUserProfile
(User me, UserMeUpdateDto userMeUpdateDto) Updates the user profile with the new given entries.
-
Konstruktordetails
-
UserService
public UserService()
-
-
Methodendetails
-
loadUserByUsername
public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String input) throws org.springframework.security.core.userdetails.UsernameNotFoundException Loads a user by username or email for authentication.- Angegeben von:
loadUserByUsername
in Schnittstelleorg.springframework.security.core.userdetails.UserDetailsService
- Parameter:
input
- the username or email- Gibt zurück:
- the user details
- Löst aus:
org.springframework.security.core.userdetails.UsernameNotFoundException
- if no matching user is found
-
findUserById
-
createUserResponseDto
Creates a public-facing user DTO from aUser
entity. Intended for returning limited user info (e.g. in contact lists).- Parameter:
user
- the user entity- Gibt zurück:
- a public response DTO
-
createUserMeResponseDto
Creates a detailed user DTO from aUser
entity, including sensitive fields like email. Intended for authenticated users accessing their own profile.- Parameter:
user
- the user entity- Gibt zurück:
- a full response DTO for the currently authenticated user
-
registerUser
Registers a new user if the provided email and username are not already in use.- Parameter:
userMeRegistrationDto
- the user input data for registration- Gibt zurück:
- a DTO containing the created user's public information
- Löst aus:
ValidationException
- if the email or username already exists
-
searchUser
searches for user by their userName or email- Parameter:
username
- the userName or email to search for- Gibt zurück:
- a DTO containing the user's public information
- Löst aus:
org.springframework.security.core.userdetails.UsernameNotFoundException
- if no matching user is found
-
updateUserProfile
Updates the user profile with the new given entries. Authentication required for username, email and new password.- Parameter:
me
- user entity that profile should be updateduserMeUpdateDto
- request dto with the new data- Gibt zurück:
- a full response DTO for the currently authenticated user
- Löst aus:
PasswordErrorException
- if password input for authentication is incorrectValidationException
- if username or email already exists
-
deleteUserProfile
Deletes a user profile and manages the handling for deleting the contacts and assignments for that user. Additional handles the deleting of not assigned recommendations- Parameter:
me
- user that should deleteuserMeDeleteDto
- the dto for the request
-