Interface PostRepositoryAdapter
- All Known Implementing Classes:
PostRepositoryAdapterImpl
public interface PostRepositoryAdapter
Adapter for post repository operations with exception handling.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteById(Long postId) Deletes a post by its ID with exception translation.booleanexistsById(long postId) Checks if a post exists by its ID.booleanexistsByIdAndAuthorId(long postId, long authorId) Checks if a post exists by its ID and author ID.findByAuthorId(long userId) Retrieves all posts authored by the specified user with exception translation.findById(long postId) Retrieves a post by its ID with exception translation.findBySlug(String slug) Retrieves a post by its unique slug identifier with exception translation.save(PostEntity postEntity) Saves a new post entity with exception translation.update(PostEntity postEntity) Updates a post entity with exception translation.
-
Method Details
-
findByAuthorId
Retrieves all posts authored by the specified user with exception translation.- Parameters:
userId- the ID of the author- Returns:
- list of posts by the author
- Throws:
FailedToFindPostsByAuthorIdException- if the repository operation fails
-
deleteById
Deletes a post by its ID with exception translation.- Parameters:
postId- the ID of the post to delete- Throws:
PostNotFoundException- if the post does not existFailedToDeletePostException- if the repository operation fails
-
findBySlug
Retrieves a post by its unique slug identifier with exception translation.- Parameters:
slug- the unique slug of the post- Returns:
- the post entity
- Throws:
PostNotFoundException- if the post does not exist
-
existsById
boolean existsById(long postId) Checks if a post exists by its ID.- Parameters:
postId- the ID of the post- Returns:
- true if the post exists, false otherwise
-
existsByIdAndAuthorId
boolean existsByIdAndAuthorId(long postId, long authorId) Checks if a post exists by its ID and author ID.- Parameters:
postId- the ID of the authorauthorId- the ID of the author- Returns:
- true if the post exists and belongs to the author, false otherwise
-
findById
Retrieves a post by its ID with exception translation.- Parameters:
postId- the ID of the post- Returns:
- the post entity
- Throws:
PostNotFoundException- if the post does not existFailedToFindPostByIdException- if the repository operation fails
-
update
Updates a post entity with exception translation.- Parameters:
postEntity- the post entity to update- Returns:
- the updated post entity
- Throws:
FailedToUpdatePostException- if the repository operation fails
-
save
Saves a new post entity with exception translation.- Parameters:
postEntity- the post entity to save- Returns:
- the saved post entity with generated ID
- Throws:
FailedToSavePostException- if the repository operation fails
-