mirror of https://github.com/halo-dev/halo
feat: support remove in batch api for comment.
parent
2a077fe04c
commit
f36f8aed8a
|
@ -98,11 +98,17 @@ public class PostCommentController {
|
||||||
|
|
||||||
@DeleteMapping("{commentId:\\d+}")
|
@DeleteMapping("{commentId:\\d+}")
|
||||||
@ApiOperation("Deletes comment permanently and recursively")
|
@ApiOperation("Deletes comment permanently and recursively")
|
||||||
public BaseCommentDTO deleteBy(@PathVariable("commentId") Long commentId) {
|
public BaseCommentDTO deletePermanently(@PathVariable("commentId") Long commentId) {
|
||||||
PostComment deletedPostComment = postCommentService.removeById(commentId);
|
PostComment deletedPostComment = postCommentService.removeById(commentId);
|
||||||
return postCommentService.convertTo(deletedPostComment);
|
return postCommentService.convertTo(deletedPostComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@ApiOperation("Delete post comments permanently in batch by id array")
|
||||||
|
public List<PostComment> deletePermanentlyInBatch(@RequestBody List<Long> ids) {
|
||||||
|
return postCommentService.removeByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("{commentId:\\d+}")
|
@GetMapping("{commentId:\\d+}")
|
||||||
@ApiOperation("Gets a post comment by comment id")
|
@ApiOperation("Gets a post comment by comment id")
|
||||||
public PostCommentWithPostVO getBy(@PathVariable("commentId") Long commentId) {
|
public PostCommentWithPostVO getBy(@PathVariable("commentId") Long commentId) {
|
||||||
|
|
|
@ -93,11 +93,17 @@ public class SheetCommentController {
|
||||||
|
|
||||||
@DeleteMapping("{commentId:\\d+}")
|
@DeleteMapping("{commentId:\\d+}")
|
||||||
@ApiOperation("Deletes comment permanently and recursively")
|
@ApiOperation("Deletes comment permanently and recursively")
|
||||||
public BaseCommentDTO deleteBy(@PathVariable("commentId") Long commentId) {
|
public BaseCommentDTO deletePermanently(@PathVariable("commentId") Long commentId) {
|
||||||
SheetComment deletedSheetComment = sheetCommentService.removeById(commentId);
|
SheetComment deletedSheetComment = sheetCommentService.removeById(commentId);
|
||||||
return sheetCommentService.convertTo(deletedSheetComment);
|
return sheetCommentService.convertTo(deletedSheetComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@ApiOperation("Delete post comments permanently in batch by id array")
|
||||||
|
public List<SheetComment> deletePermanentlyInBatch(@RequestBody List<Long> ids) {
|
||||||
|
return sheetCommentService.removeByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("{commentId:\\d+}")
|
@GetMapping("{commentId:\\d+}")
|
||||||
@ApiOperation("Gets a post comment by comment id")
|
@ApiOperation("Gets a post comment by comment id")
|
||||||
public SheetCommentWithSheetVO getBy(@PathVariable("commentId") Long commentId) {
|
public SheetCommentWithSheetVO getBy(@PathVariable("commentId") Long commentId) {
|
||||||
|
|
|
@ -23,7 +23,8 @@ import java.util.Map;
|
||||||
* Base comment service interface.
|
* Base comment service interface.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
* @date 19-4-24
|
* @author ryanwang
|
||||||
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
public interface BaseCommentService<COMMENT extends BaseComment> extends CrudService<COMMENT, Long> {
|
public interface BaseCommentService<COMMENT extends BaseComment> extends CrudService<COMMENT, Long> {
|
||||||
|
|
||||||
|
@ -149,6 +150,15 @@ public interface BaseCommentService<COMMENT extends BaseComment> extends CrudSer
|
||||||
@NonNull
|
@NonNull
|
||||||
COMMENT updateStatus(@NonNull Long commentId, @NonNull CommentStatus status);
|
COMMENT updateStatus(@NonNull Long commentId, @NonNull CommentStatus status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes comments in batch.
|
||||||
|
*
|
||||||
|
* @param ids ids must not be null.
|
||||||
|
* @return a list of deleted comment.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
List<COMMENT> removeByIds(@NonNull Collection<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts to base comment dto.
|
* Converts to base comment dto.
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,6 +51,7 @@ import java.util.stream.Collectors;
|
||||||
* Base comment service implementation.
|
* Base comment service implementation.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 2019-04-24
|
* @date 2019-04-24
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -328,6 +329,14 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
|
||||||
return updatedComment;
|
return updatedComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<COMMENT> removeByIds(Collection<Long> ids) {
|
||||||
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return ids.stream().map(this::removeById).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BaseCommentDTO> convertTo(List<COMMENT> comments) {
|
public List<BaseCommentDTO> convertTo(List<COMMENT> comments) {
|
||||||
if (CollectionUtils.isEmpty(comments)) {
|
if (CollectionUtils.isEmpty(comments)) {
|
||||||
|
|
Loading…
Reference in New Issue