mirror of https://github.com/halo-dev/halo
Perfect sheet and journal comment controller
parent
619d30bac3
commit
c454acd4a9
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue