Interface UserService
- All Known Implementing Classes:
UserServiceImpl
public interface UserService
Manages user lifecycle operations.
-
Method Summary
Modifier and TypeMethodDescriptioncreateUser(CreateUserCommand command) Creates a new user in the system.getUserByUsername(String username) Retrieves complete user profile with posts by username.getUserByUsernameOrEmail(String usernameOrEmail) Retrieves a user by username or email address.updateUserProfile(Long id, UpdateUserRequestDTO requestDTO, MultipartFile profilePicture) Updates user profile with optional field updates and profile picture replacement.
-
Method Details
-
createUser
Creates a new user in the system.- Parameters:
command- user creation details- Returns:
- the persisted user entity
- Throws:
UsernameTakenException- if username already existsEmailTakenException- if email already existsFailedToCreateUserException- for other persistence failures
-
getUserByUsernameOrEmail
Retrieves a user by username or email address.- Parameters:
usernameOrEmail- the username or email to search for- Returns:
- the matching user entity
- Throws:
UserNotFoundException- if no user is foundFailedToFindUserException- for database errors
-
getUserByUsername
Retrieves complete user profile with posts by username.- Parameters:
username- the username to search for- Returns:
- user data transfer object with profile information and post summaries
- Throws:
UserNotFoundException- if no user is foundFailedToFindUserException- for database errors
-
updateUserProfile
UpdateUserResponseDTO updateUserProfile(Long id, UpdateUserRequestDTO requestDTO, MultipartFile profilePicture) Updates user profile with optional field updates and profile picture replacement. Supports partial updates - only non-null fields are modified. If a new profile picture is provided, the old one is deleted after successful update.- Parameters:
id- the user ID to updaterequestDTO- DTO containing fields to update (all fields optional)profilePicture- optional new profile picture file- Returns:
- response DTO with updated profile information
- Throws:
UserNotFoundException- if user with given ID is not foundUsernameTakenException- if new username is already takenEmailTakenException- if new email is already takenFailedToUpdateUserException- for database update failures
-