Class ReactionController
java.lang.Object
com.example.blogs.app.api.reaction.controller.ReactionController
Handles HTTP requests for reaction-related operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsetReaction(Long postId, UserPrincipal userPrincipal, @Valid @NotNull ReactionSetRequestDTO requestDTO) Sets or updates a reaction on a post.
-
Constructor Details
-
ReactionController
public ReactionController()
-
-
Method Details
-
setReaction
@PostMapping("/posts/{postId}/reactions") public ResponseEntity<ReactionDTO> setReaction(@PathVariable Long postId, @AuthenticationPrincipal UserPrincipal userPrincipal, @Valid @NotNull @RequestBody @Valid @NotNull ReactionSetRequestDTO requestDTO) Sets or updates a reaction on a post. If the user has already reacted, updates the reaction type. If the user hasn't reacted yet, creates a new reaction.- Parameters:
postId- the ID of the post to react touserPrincipal- authenticated user making the reactionrequestDTO- request containing the reaction type- Returns:
- the created or updated reaction with HTTP 200 status
-