feat(biji-houdaun): 支持 Markdown 文件上传、预览、编辑和创建
- 新增 Markdown 文件预览功能 - 更新 Markdown 文件创建和编辑接口,使用 Long 类型的 ID - 优化图片上传接口,支持 Long 类型的用户 ID 和 Markdown ID - 重构 MarkdownFileService接口,增加获取 Markdown 文件的方法 - 修改 MarkdownFileServiceImpl 实现类,支持新的 Markdown 文件操作
This commit is contained in:
@@ -31,8 +31,8 @@ public class ImageController {
|
||||
})
|
||||
@PostMapping
|
||||
public ResponseEntity<Image> uploadImage(
|
||||
@RequestParam Integer userId,
|
||||
@RequestParam(required = false) Integer markdownId,
|
||||
@RequestParam Long userId,
|
||||
@RequestParam(required = false) Long markdownId,
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
try {
|
||||
@@ -42,4 +42,4 @@ public class ImageController {
|
||||
return ResponseEntity.status(500).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,19 @@ public class MarkdownController {
|
||||
@Autowired
|
||||
private MarkdownFileService markdownFileService;
|
||||
|
||||
@Operation(summary = "预览markdown文件")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "文件ID", required = true)
|
||||
})
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<String> getMarkdownContent(@PathVariable Long id) {
|
||||
MarkdownFile file = markdownFileService.getMarkdownById(id);
|
||||
if (file != null) {
|
||||
return ResponseEntity.ok(file.getContent());
|
||||
}
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@Operation(summary = "创建markdown文件")
|
||||
@Parameters({
|
||||
@Parameter(name = "userId", description = "用户id",required = true),
|
||||
@@ -26,7 +39,7 @@ public class MarkdownController {
|
||||
})
|
||||
@PostMapping
|
||||
public ResponseEntity<MarkdownFile> createMarkdown(
|
||||
@RequestParam Integer userId,
|
||||
@RequestParam Long userId,
|
||||
@RequestParam String title,
|
||||
@RequestParam String fileName,
|
||||
@RequestBody String content) {
|
||||
@@ -44,7 +57,7 @@ public class MarkdownController {
|
||||
})
|
||||
@PostMapping("/{id}")
|
||||
public ResponseEntity<MarkdownFile> updateMarkdown(
|
||||
@PathVariable Integer id,
|
||||
@PathVariable Long id,
|
||||
@RequestBody String content) {
|
||||
|
||||
MarkdownFile file = markdownFileService.updateMarkdownContent(id, content);
|
||||
|
||||
Reference in New Issue
Block a user