Class ReactionRepositoryAdapterImpl
java.lang.Object
com.example.blogs.app.api.reaction.repository.adapter.ReactionRepositoryAdapterImpl
- All Implemented Interfaces:
ReactionRepositoryAdapter
@Component
public class ReactionRepositoryAdapterImpl
extends Object
implements ReactionRepositoryAdapter
Wraps reaction repository operations with exception translation for consistent error handling.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindByPostIdAndUserId(Long postId, Long userId) Finds a reaction by post ID and user ID with exception translation.save(ReactionEntity reactionEntity) Saves a reaction entity to the database with exception translation.
-
Constructor Details
-
ReactionRepositoryAdapterImpl
public ReactionRepositoryAdapterImpl()
-
-
Method Details
-
save
Saves a reaction entity to the database with exception translation. Detects unique constraint violations and wraps repository exceptions.- Specified by:
savein interfaceReactionRepositoryAdapter- Parameters:
reactionEntity- the reaction entity to save- Returns:
- the saved reaction entity with generated ID
- Throws:
UserHasAlreadyReactedException- if user already has a reaction on this postFailedToSaveReactionException- if the save operation fails
-
findByPostIdAndUserId
Finds a reaction by post ID and user ID with exception translation. Wraps repository exceptions in domain-specific exceptions for consistent error handling.- Specified by:
findByPostIdAndUserIdin interfaceReactionRepositoryAdapter- Parameters:
postId- the ID of the postuserId- the ID of the user- Returns:
- the reaction entity if found
- Throws:
ReactionNotFoundException- if the reaction does not existFailedToFindReactionException- if the find operation fails
-