Complete delete comment api

pull/137/head
johnniang 2019-03-25 19:33:50 +08:00
parent 6b0dc1ce5e
commit 836e9975e8
1 changed files with 12 additions and 2 deletions

View File

@ -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);
}
} }