CommentController

@RestController
@RequestMapping(value = ["/api/v1/articles/{articleId}/comments"])
class CommentController(commentService: CommentService)

Constructors

Link copied to clipboard
constructor(commentService: CommentService)

Functions

Link copied to clipboard
@PostMapping
@PreAuthorize(value = "isAuthenticated()")
@ResponseStatus(value = HttpStatus.CREATED)
fun createComment(@AuthenticationPrincipal userDetails: UserDetails, @PathVariable articleId: Long, @Valid @RequestBody commentForm: CommentForm): ResponseEntity<CommentResponse>
Link copied to clipboard
@DeleteMapping(value = ["/{commentId}"])
@PreAuthorize(value = "isAuthenticated() and @commentValidator.isAuthor(#articleId, #commentId, #userDetails.username)")
fun deleteComment(@PathVariable articleId: Long, @PathVariable commentId: Long, @AuthenticationPrincipal userDetails: UserDetails): ResponseEntity<Unit>
Link copied to clipboard
@PatchMapping(value = ["/{commentId}"])
@PreAuthorize(value = "isAuthenticated() and @commentValidator.isAuthor(#articleId, #commentId, #userDetails.username)")
fun updateComment(@PathVariable articleId: Long, @PathVariable commentId: Long, @Valid @RequestBody commentForm: CommentForm, @AuthenticationPrincipal userDetails: UserDetails): ResponseEntity<CommentResponse>