Interface PostService

All Known Implementing Classes:
PostServiceImpl

public interface PostService
Service for post-related business operations.
  • Method Details

    • getPostsByUserId

      List<PostEntity> getPostsByUserId(long userId)
      Retrieves all posts created by the specified user.
      Parameters:
      userId - the ID of the user
      Returns:
      list of posts created by the user
    • deletePostById

      void deletePostById(Long postId)
      Deletes a post by its ID.
      Parameters:
      postId - the ID of the post to delete
    • getPostBySlug

      PostDTO getPostBySlug(String slug)
      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 update
      requestDTO - the update request containing fields to update
      previewImage - 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 post
      requestDTO - the post creation request containing title, description, and content
      previewImage - the preview image file to upload
      Returns:
      created post details with generated slug and preview image URL