Interface CommentService
- All Known Implementing Classes:
CommentServiceImpl
public interface CommentService
Service for comment-related business operations.
-
Method Summary
Modifier and TypeMethodDescriptioncreateComment(Long postId, Long userId, CommentWriteRequestDTO requestDTO) Creates a new comment on a specific post.voiddeleteCommentById(Long commentId) Deletes a comment by its ID.getCommentsByPostId(Long postId) Retrieves all comments associated with a specific post.updateCommentById(Long commentId, CommentWriteRequestDTO requestDTO) Updates a comment by its ID with new content.
-
Method Details
-
getCommentsByPostId
Retrieves all comments associated with a specific post.- Parameters:
postId- the ID of the post- Returns:
- list of comments for the post
-
createComment
Creates a new comment on a specific post. Validates post and user existence, saves the comment, and returns the created comment.- Parameters:
postId- the ID of the post to comment onuserId- the ID of the user creating the commentrequestDTO- request containing the comment content- Returns:
- newly created comment as DTO
-
deleteCommentById
Deletes a comment by its ID. Removes the comment from the database.- Parameters:
commentId- the ID of the comment to delete
-
updateCommentById
Updates a comment by its ID with new content. Marks the comment as edited and persists the changes.- Parameters:
commentId- the ID of the comment to updaterequestDTO- request containing the updated comment content- Returns:
- updated comment as DTO
-