feat(biji): 优化笔记展示功能并调整端口

-将服务器端口从 8083 改为 8084
- 在数据库中添加 grouping_id 字段
- 实现笔记分组展示功能
-优化笔记编辑页面布局
-重构后端接口返回类型
- 移除 MarkdownFile 实体中的 userId 字段
This commit is contained in:
ikmkj
2025-06-17 21:54:53 +08:00
parent 4557bd49f9
commit b1b74f5efd
7 changed files with 90 additions and 31 deletions

View File

@@ -8,7 +8,6 @@ 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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -33,12 +32,12 @@ public class MarkdownController {
@Parameter(name = "id", description = "文件ID", required = true)
})
@GetMapping("/{id}")
public ResponseEntity<String> getMarkdownContent(@PathVariable Long id) {
public R<String> getMarkdownContent(@PathVariable Long id) {
MarkdownFile file = markdownFileService.getMarkdownById(id);
if (file != null) {
return ResponseEntity.ok(file.getContent());
return R.success(file.getContent());
}
return ResponseEntity.notFound().build();
return R.fail();
}
@Operation(summary = "创建markdown文件")
@@ -49,7 +48,7 @@ public class MarkdownController {
@Parameter(name = "content", description = "内容",required = true)
})
@PostMapping
public ResponseEntity<MarkdownFile> createMarkdown(
public R<MarkdownFile> createMarkdown(
@RequestParam Long groupingId,
@RequestParam String title,
@RequestParam String fileName,
@@ -58,7 +57,7 @@ public class MarkdownController {
MarkdownFile file = markdownFileService.createMarkdownFile(
groupingId, title, fileName, content);
return ResponseEntity.ok(file);
return R.success(file);
}
@Operation(summary = "更新Markdown文件")
@@ -67,39 +66,38 @@ public class MarkdownController {
@Parameter(name = "content", description = "Markdown文件内容", required = true)
})
@PostMapping("/{id}")
public ResponseEntity<MarkdownFile> updateMarkdown(
public R<MarkdownFile> updateMarkdown(
@PathVariable Long id,
@RequestBody String content) {
MarkdownFile file = markdownFileService.updateMarkdownContent(id, content);
if (file != null) {
return ResponseEntity.ok(file);
return R.success(file);
}
return ResponseEntity.notFound().build();
return R.fail();
}
@Operation(summary = "获取所有Markdown文件")
@GetMapping
public ResponseEntity<List<MarkdownFile>> getAllMarkdownFiles() {
// 固定用户ID=1因为是个人笔记
public R<List<MarkdownFile>> getAllMarkdownFiles() {
List<MarkdownFile> files = markdownFileService.getAllMarkdownFiles();
return ResponseEntity.ok(files);
return R.success(files);
}
@Operation(summary = "删除Markdown文件")
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteMarkdown(@PathVariable Long id) {
public R<Void> deleteMarkdown(@PathVariable Long id) {
if (markdownFileService.deleteMarkdownFile(id)) {
return ResponseEntity.noContent().build();
return R.success();
}
return ResponseEntity.notFound().build();
return R.fail();
}
@Operation(summary = "根据分组ID获取Markdown文件")
@GetMapping("/grouping/{groupingId}")
public ResponseEntity<List<MarkdownFile>> getFilesByGroupingId(@PathVariable String groupingId) {
public R<List<MarkdownFile>> getFilesByGroupingId(@PathVariable String groupingId) {
List<MarkdownFile> files = markdownFileService.getFilesByGroupingId(groupingId);
return ResponseEntity.ok(files);
return R.success(files);
}
}

View File

@@ -18,8 +18,6 @@ public class MarkdownFile {
private Long id;
@Schema(description = "分组表id",implementation = Long.class)
private Long groupingId;
@Schema(description = "用户ID",implementation = Long.class)
private Long userId;
@Schema(description = "文本标题",implementation = String.class)
private String title;

View File

@@ -11,7 +11,6 @@ import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;