Interface PostMapper


public interface PostMapper
Mapper for converting between post entities and DTOs.
  • Method Details

    • toPostDTO

      PostDTO toPostDTO(PostEntity post, List<CommentEntity> comments, String postPreviewImageUrl, String profilePictureUrl)
      Converts a post entity and its comments to a post DTO.
      Parameters:
      post - the post entity
      comments - the list of comments associated with the post
      postPreviewImageUrl - the URL of the preview image
      profilePictureUrl - the URL of the author's profile picture
      Returns:
      post DTO with comment summaries
    • toPostUserSummaryDTO

      PostUserSummaryDTO toPostUserSummaryDTO(UserEntity user, String profilePictureUrl)
      Converts a user entity to a user summary DTO.
      Parameters:
      user - the user entity
      profilePictureUrl - the URL of the user's profile picture
      Returns:
      user summary DTO
    • toPostCommentSummaryDTO

      PostCommentSummaryDTO toPostCommentSummaryDTO(CommentEntity comment, String profilePictureUrl)
      Converts a comment entity to a post comment summary DTO.
      Parameters:
      comment - the comment entity
      profilePictureUrl - the URL of the comment author's profile picture
      Returns:
      post comment summary DTO
    • toPostEntity

      PostEntity toPostEntity(PostUpdateRequestDTO requestDTO, PostEntity postEntity)
      Updates a post entity with non-null fields from the request DTO. Null values in the request are ignored, preserving existing entity values.
      Parameters:
      requestDTO - the update request containing fields to update
      postEntity - the existing post entity to update
      Returns:
      updated post entity with merged values
    • toPostEntity

      PostEntity toPostEntity(PostCreateRequestDTO requestDTO, String slug, FileEntity file, UserEntity author)
      Converts a post creation request to a post entity with generated slug, file, and author.
      Parameters:
      requestDTO - the post creation request containing title, description, and content
      slug - the generated unique slug for the post
      file - the uploaded file entity for the preview image
      author - the author entity creating the post
      Returns:
      post entity ready for persistence
    • toPostUpdateResponseDTO

      PostUpdateResponseDTO toPostUpdateResponseDTO(PostEntity postEntity, String previewImageUrl)
      Converts a post entity to a post update response DTO.
      Parameters:
      postEntity - the post entity
      previewImageUrl - the URL of the preview image
      Returns:
      post update response DTO
    • toPostCreateResponseDTO

      PostCreateResponseDTO toPostCreateResponseDTO(PostEntity postEntity, String previewImageUrl)
      Converts a post entity to a post creation response DTO with preview image URL.
      Parameters:
      postEntity - the created post entity
      previewImageUrl - the generated URL for the preview image
      Returns:
      post creation response DTO with all post details