feat(qianduan): 优化笔记功能和图片处理
- 新增批量删除图片接口和功能- 实现笔记中图片的上传和删除 - 优化笔记保存时的图片处理逻辑 -调整分组展示和Markdown文件加载方式
This commit is contained in:
@@ -4,6 +4,8 @@ import com.test.bijihoudaun.common.response.R;
|
||||
import com.test.bijihoudaun.entity.Grouping;
|
||||
import com.test.bijihoudaun.service.GroupingService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -26,9 +28,16 @@ public class GroupingController {
|
||||
}
|
||||
|
||||
@Operation(summary = "获取全部分组")
|
||||
@Parameters({
|
||||
@Parameter(name = "parentId", description = "0是一级,其他的是看它的父级id", required = true)
|
||||
})
|
||||
@GetMapping
|
||||
public R<List<Grouping>> getAllGroupings() {
|
||||
List<Grouping> groupings = groupingService.getAllGroupings();
|
||||
public R<List<Grouping>> getAllGroupings(String parentId) {
|
||||
if (parentId == null) {
|
||||
return R.fail("参数不能为空");
|
||||
}
|
||||
long l = Long.parseLong(parentId);
|
||||
List<Grouping> groupings = groupingService.getAllGroupings(l);
|
||||
return R.success(groupings);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -86,9 +86,13 @@ public class MarkdownController {
|
||||
}
|
||||
|
||||
@Operation(summary = "删除Markdown文件")
|
||||
@DeleteMapping("/{id}")
|
||||
public R<Void> deleteMarkdown(@PathVariable Long id) {
|
||||
if (markdownFileService.deleteMarkdownFile(id)) {
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "Markdown文件ID", required = true),
|
||||
})
|
||||
@PostMapping("/delete")
|
||||
public R<Void> deleteMarkdown(String id) {
|
||||
long l = Long.parseLong(id);
|
||||
if (markdownFileService.deleteMarkdownFile(l)) {
|
||||
return R.success();
|
||||
}
|
||||
return R.fail();
|
||||
|
||||
Reference in New Issue
Block a user