From 5959fdfa2d2070b0fded5f9c4a9ed2ab7670b40e Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 25 Feb 2022 15:55:11 +0800 Subject: [PATCH] feat: add api for delete photos in batch Signed-off-by: Ryan Wang --- .../halo/app/controller/admin/api/PhotoController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/run/halo/app/controller/admin/api/PhotoController.java b/src/main/java/run/halo/app/controller/admin/api/PhotoController.java index 4ff968ce02..66ec9b144a 100644 --- a/src/main/java/run/halo/app/controller/admin/api/PhotoController.java +++ b/src/main/java/run/halo/app/controller/admin/api/PhotoController.java @@ -72,6 +72,14 @@ public void deletePermanently(@PathVariable("photoId") Integer photoId) { photoService.removeById(photoId); } + @DeleteMapping("/batch") + @ApiOperation("Deletes photos permanently in batch by id array") + public List deletePermanentlyInBatch(@RequestBody List ids) { + return ids.stream().map(photoService::removeById) + .map(photo -> (PhotoDTO) new PhotoDTO().convertFrom(photo)) + .collect(Collectors.toList()); + } + @PostMapping @ApiOperation("Creates a photo") public PhotoDTO createBy(@Valid @RequestBody PhotoParam photoParam) {