Interface UserService

All Known Implementing Classes:
UserServiceImpl

public interface UserService
Manages user lifecycle operations.
  • Method Details

    • createUser

      UserEntity createUser(CreateUserCommand command)
      Creates a new user in the system.
      Parameters:
      command - user creation details
      Returns:
      the persisted user entity
      Throws:
      UsernameTakenException - if username already exists
      EmailTakenException - if email already exists
      FailedToCreateUserException - for other persistence failures
    • getUserByUsernameOrEmail

      UserEntity getUserByUsernameOrEmail(String usernameOrEmail)
      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 found
      FailedToFindUserException - for database errors
    • getUserByUsername

      UserDTO getUserByUsername(String username)
      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 found
      FailedToFindUserException - 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 update
      requestDTO - 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 found
      UsernameTakenException - if new username is already taken
      EmailTakenException - if new email is already taken
      FailedToUpdateUserException - for database update failures