Interface PostMapper
public interface PostMapper
Mapper for converting between post entities and DTOs.
-
Method Summary
Modifier and TypeMethodDescriptiontoPostCommentSummaryDTO(CommentEntity comment, String profilePictureUrl) Converts a comment entity to a post comment summary DTO.toPostCreateResponseDTO(PostEntity postEntity, String previewImageUrl) Converts a post entity to a post creation response DTO with preview image URL.toPostDTO(PostEntity post, List<CommentEntity> comments, String postPreviewImageUrl, String profilePictureUrl) Converts a post entity and its comments to a post DTO.toPostEntity(PostCreateRequestDTO requestDTO, String slug, FileEntity file, UserEntity author) Converts a post creation request to a post entity with generated slug, file, and author.toPostEntity(PostUpdateRequestDTO requestDTO, PostEntity postEntity) Updates a post entity with non-null fields from the request DTO.toPostUpdateResponseDTO(PostEntity postEntity, String previewImageUrl) Converts a post entity to a post update response DTO.toPostUserSummaryDTO(UserEntity user, String profilePictureUrl) Converts a user entity to a user summary DTO.
-
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 entitycomments- the list of comments associated with the postpostPreviewImageUrl- the URL of the preview imageprofilePictureUrl- the URL of the author's profile picture- Returns:
- post DTO with comment summaries
-
toPostUserSummaryDTO
Converts a user entity to a user summary DTO.- Parameters:
user- the user entityprofilePictureUrl- the URL of the user's profile picture- Returns:
- user summary DTO
-
toPostCommentSummaryDTO
Converts a comment entity to a post comment summary DTO.- Parameters:
comment- the comment entityprofilePictureUrl- the URL of the comment author's profile picture- Returns:
- post comment summary DTO
-
toPostEntity
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 updatepostEntity- 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 contentslug- the generated unique slug for the postfile- the uploaded file entity for the preview imageauthor- the author entity creating the post- Returns:
- post entity ready for persistence
-
toPostUpdateResponseDTO
Converts a post entity to a post update response DTO.- Parameters:
postEntity- the post entitypreviewImageUrl- the URL of the preview image- Returns:
- post update response DTO
-
toPostCreateResponseDTO
Converts a post entity to a post creation response DTO with preview image URL.- Parameters:
postEntity- the created post entitypreviewImageUrl- the generated URL for the preview image- Returns:
- post creation response DTO with all post details
-