feat(image): 添加图片删除功能并优化 Markdown 编辑器

- 在 ImageController 中添加删除图片的接口
- 在 ImageService 中实现删除图片和批量更新图片 ID 的方法
- 在前端集成复制代码插件并优化 Markdown 编辑器配置
- 修复后端分组相关接口的参数类型问题
This commit is contained in:
ikmkj
2025-06-20 09:35:19 +08:00
parent df848fed23
commit 12ba82eaa1
8 changed files with 145 additions and 27 deletions

View File

@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
@Tag(name = "markdown接口")
@RestController
@RequestMapping("/api/images")
@@ -28,14 +30,39 @@ public class ImageController {
})
@PostMapping
public R<Image> uploadImage(
@RequestParam(required = false) Long markdownId,
@RequestParam(required = false) String markdownId,
@RequestParam("file") MultipartFile file) {
try {
Image image = imageService.uploadImage(markdownId, file);
Long markdownIdLong = Long.parseLong(markdownId);
Image image = imageService.uploadImage(markdownIdLong, file);
return R.success(image);
} catch (IOException e) {
return R.fail();
}
}
@Operation(summary = "根据id删除图片")
@DeleteMapping("/{id}")
public R<Void> deleteImage(@PathVariable Long id) {
boolean result = imageService.deleteImage(id);
if (result) {
return R.success();
} else {
return R.fail();
}
}
@Operation(summary = "根据url删除图片")
@DeleteMapping
public R<Void> deleteImageByUrl(@RequestParam String url) {
boolean result = imageService.deleteImageByUrl(url);
if (result) {
return R.success();
} else {
return R.fail();
}
}
}