Interface PostService
- All Known Implementing Classes:
PostServiceImpl
public interface PostService
Service for post-related business operations.
-
Method Summary
Modifier and TypeMethodDescriptioncreatePost(long authorId, PostCreateRequestDTO requestDTO, MultipartFile previewImage) Creates a new post with a preview image and generates a unique slug.voiddeletePostById(Long postId) Deletes a post by its ID.getPostBySlug(String slug) Retrieves a post by its unique slug identifier with associated comments.getPostsByUserId(long userId) Retrieves all posts created by the specified user.updatePostById(long postId, PostUpdateRequestDTO requestDTO, MultipartFile previewImage) Updates a post by its ID with partial field updates.
-
Method Details
-
getPostsByUserId
Retrieves all posts created by the specified user.- Parameters:
userId- the ID of the user- Returns:
- list of posts created by the user
-
deletePostById
Deletes a post by its ID.- Parameters:
postId- the ID of the post to delete
-
getPostBySlug
Retrieves a post by its unique slug identifier with associated comments.- Parameters:
slug- the unique slug of the post- Returns:
- post details with associated comments
-
updatePostById
PostUpdateResponseDTO updatePostById(long postId, PostUpdateRequestDTO requestDTO, MultipartFile previewImage) Updates a post by its ID with partial field updates. If the title is updated, a new slug is generated.- Parameters:
postId- the ID of the post to updaterequestDTO- the update request containing fields to updatepreviewImage- the new preview image file to upload (optional)- Returns:
- updated post details with new timestamp
-
createPost
PostCreateResponseDTO createPost(long authorId, PostCreateRequestDTO requestDTO, MultipartFile previewImage) Creates a new post with a preview image and generates a unique slug.- Parameters:
authorId- the ID of the user creating the postrequestDTO- the post creation request containing title, description, and contentpreviewImage- the preview image file to upload- Returns:
- created post details with generated slug and preview image URL
-