feat(qianduan): 优化笔记功能和图片处理
- 新增批量删除图片接口和功能- 实现笔记中图片的上传和删除 - 优化笔记保存时的图片处理逻辑 -调整分组展示和Markdown文件加载方式
This commit is contained in:
@@ -25,17 +25,14 @@ public class ImageController {
|
||||
|
||||
@Operation(summary = "上传图片")
|
||||
@Parameters({
|
||||
@Parameter(name = "markdownId", description = "markdownid", required = true),
|
||||
@Parameter(name = "file", description = "图片文件", required = true)
|
||||
})
|
||||
@PostMapping
|
||||
public R<Image> uploadImage(
|
||||
@RequestParam(required = false) String markdownId,
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
try {
|
||||
Long markdownIdLong = Long.parseLong(markdownId);
|
||||
Image image = imageService.uploadImage(markdownIdLong, file);
|
||||
Image image = imageService.uploadImage(file);
|
||||
return R.success(image);
|
||||
} catch (IOException e) {
|
||||
return R.fail();
|
||||
@@ -43,7 +40,7 @@ public class ImageController {
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id删除图片")
|
||||
@DeleteMapping("/{id}")
|
||||
@PostMapping("/{id}")
|
||||
public R<Void> deleteImage(@PathVariable Long id) {
|
||||
boolean result = imageService.deleteImage(id);
|
||||
if (result) {
|
||||
@@ -54,7 +51,7 @@ public class ImageController {
|
||||
}
|
||||
|
||||
@Operation(summary = "根据url删除图片")
|
||||
@DeleteMapping
|
||||
@PostMapping("/deleteByUrl")
|
||||
public R<Void> deleteImageByUrl(@RequestParam String url) {
|
||||
boolean result = imageService.deleteImageByUrl(url);
|
||||
if (result) {
|
||||
@@ -64,5 +61,16 @@ public class ImageController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "根据url批量删除图片")
|
||||
@PostMapping("/batch")
|
||||
public R<Void> deleteImageByUrls(@RequestBody List<String> urls) {
|
||||
boolean result = imageService.deleteImageByUrls(urls);
|
||||
if (result) {
|
||||
return R.success();
|
||||
} else {
|
||||
return R.fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user