Interface UserMapper


public interface UserMapper
MapStruct mapper for converting user entities and posts to data transfer objects.
  • Method Details

    • toUserDTO

      UserDTO toUserDTO(UserEntity userEntity, List<PostEntity> posts, String profilePictureUrl)
      Maps user entity and associated posts to a complete user DTO.
      Parameters:
      userEntity - user entity with profile information
      posts - list of post entities authored by the user
      profilePictureUrl - URL of the user's profile picture to include in the post summary
      Returns:
      user DTO with profile and post summaries
    • toUserPostSummaryDto

      UserPostSummaryDTO toUserPostSummaryDto(PostEntity postEntity, String profilePictureUrl)
      Maps a post entity to a post summary DTO.
      Parameters:
      postEntity - post entity to map
      profilePictureUrl - URL of the user's profile picture to include in the post summary
      Returns:
      post summary DTO
    • toUserEntity

      UserEntity toUserEntity(Long id)
      Creates a user entity with only the ID populated.
      Parameters:
      id - the user ID
      Returns:
      user entity with only ID set
    • toUserEntity

      UserEntity toUserEntity(UpdateUserRequestDTO requestDTO, UserEntity userEntity, String passwordHash)
      Updates user entity with values from request DTO and password hash. Uses IGNORE strategy - only non-null fields from requestDTO are applied.
      Parameters:
      requestDTO - DTO containing fields to update (null fields are ignored)
      userEntity - existing user entity to update (modified in place)
      passwordHash - optional new password hash (null if password not changed)
      Returns:
      the modified user entity
    • toUpdateUserResponseDTO

      UpdateUserResponseDTO toUpdateUserResponseDTO(UserEntity userEntity, String profilePictureUrl)
      Maps user entity and profile picture URL to update response DTO.
      Parameters:
      userEntity - updated user entity
      profilePictureUrl - URL of the user's profile picture
      Returns:
      update response DTO with username, bio, and profile picture URL