Perfect sheet and journal comment controller

pull/146/head
johnniang 2019-04-26 00:13:59 +08:00
parent 619d30bac3
commit c454acd4a9
3 changed files with 33 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.BaseCommentDTO;
import run.halo.app.model.entity.JournalComment;
import run.halo.app.model.enums.CommentStatus;
import run.halo.app.model.params.CommentQuery;
import run.halo.app.model.params.JournalCommentParam;
import run.halo.app.model.vo.JournalCommentWithJournalVO;
@ -53,4 +54,19 @@ public class JournalCommentController {
return journalCommentService.convertTo(journalComment);
}
@PutMapping("{commentId:\\d+}/status/{status}")
@ApiOperation("Updates comment status")
public BaseCommentDTO updateStatusBy(@PathVariable("commentId") Long commentId,
@PathVariable("status") CommentStatus status) {
// Update comment status
JournalComment updatedJournalComment = journalCommentService.updateStatus(commentId, status);
return journalCommentService.convertTo(updatedJournalComment);
}
@DeleteMapping("{commentId:\\d+}")
@ApiOperation("Deletes comment permanently and recursively")
public BaseCommentDTO deleteBy(@PathVariable("commentId") Long commentId) {
JournalComment deletedJournalComment = journalCommentService.removeById(commentId);
return journalCommentService.convertTo(deletedJournalComment);
}
}

View File

@ -61,7 +61,6 @@ public class PostCommentController {
@PathVariable("status") CommentStatus status) {
// Update comment status
PostComment updatedPostComment = postCommentService.updateStatus(commentId, status);
return postCommentService.convertTo(updatedPostComment);
}
@ -69,7 +68,6 @@ public class PostCommentController {
@ApiOperation("Deletes comment permanently and recursively")
public BaseCommentDTO deleteBy(@PathVariable("commentId") Long commentId) {
PostComment deletedPostComment = postCommentService.removeById(commentId);
return postCommentService.convertTo(deletedPostComment);
}
}

View File

@ -7,6 +7,7 @@ import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.BaseCommentDTO;
import run.halo.app.model.entity.SheetComment;
import run.halo.app.model.enums.CommentStatus;
import run.halo.app.model.params.CommentQuery;
import run.halo.app.model.params.SheetCommentParam;
import run.halo.app.model.vo.SheetCommentWithSheetVO;
@ -51,4 +52,20 @@ public class SheetCommentController {
SheetComment createdComment = sheetCommentService.createBy(commentParam);
return sheetCommentService.convertTo(createdComment);
}
@PutMapping("{commentId:\\d+}/status/{status}")
@ApiOperation("Updates comment status")
public BaseCommentDTO updateStatusBy(@PathVariable("commentId") Long commentId,
@PathVariable("status") CommentStatus status) {
// Update comment status
SheetComment updatedSheetComment = sheetCommentService.updateStatus(commentId, status);
return sheetCommentService.convertTo(updatedSheetComment);
}
@DeleteMapping("{commentId:\\d+}")
@ApiOperation("Deletes comment permanently and recursively")
public BaseCommentDTO deleteBy(@PathVariable("commentId") Long commentId) {
SheetComment deletedSheetComment = sheetCommentService.removeById(commentId);
return sheetCommentService.convertTo(deletedSheetComment);
}
}