mirror of https://github.com/halo-dev/halo
Complete delete comment api
parent
6b0dc1ce5e
commit
836e9975e8
|
@ -71,12 +71,22 @@ public class CommentController {
|
||||||
|
|
||||||
@PutMapping("{commentId:\\d+}/status/{status}")
|
@PutMapping("{commentId:\\d+}/status/{status}")
|
||||||
@ApiOperation("Update comment status")
|
@ApiOperation("Update comment status")
|
||||||
public CommentOutputDTO deleteBy(@PathVariable("commentId") Long commentId,
|
public CommentOutputDTO updateStatusBy(@PathVariable("commentId") Long commentId,
|
||||||
@PathVariable("status") CommentStatus status) {
|
@PathVariable("status") CommentStatus status) {
|
||||||
// Update comment status
|
// Update comment status
|
||||||
Comment updatedComment = commentService.updateStatus(commentId, status);
|
Comment updatedComment = commentService.updateStatus(commentId, status);
|
||||||
|
|
||||||
return new CommentOutputDTO().convertFrom(updatedComment);
|
return new CommentOutputDTO().convertFrom(updatedComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{commentId:\\d+}")
|
||||||
|
public CommentOutputDTO deleteBy(@PathVariable("commentId") Long commentId) {
|
||||||
|
// Get comment by id
|
||||||
|
Comment comment = commentService.getById(commentId);
|
||||||
|
|
||||||
|
// Remove it
|
||||||
|
commentService.remove(comment);
|
||||||
|
|
||||||
|
return new CommentOutputDTO().convertFrom(comment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue