feat(grouping): 新增分组功能并优化 Markdown 文件操作
- 新增分组实体、控制器、服务和映射器 - 实现分组创建、获取、更新和删除接口 - 优化 Markdown 文件创建、获取和删除接口- 新增全局异常处理和日志记录 - 更新数据库表结构和字段类型 - 重构前端页面,支持分组和 Markdown 文件展示
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.test.bijihoudaun.controller;
|
||||
|
||||
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.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "分组接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/groupings")
|
||||
public class GroupingController {
|
||||
|
||||
@Autowired
|
||||
private GroupingService groupingService;
|
||||
|
||||
@Operation(summary = "创建分组")
|
||||
@PostMapping
|
||||
public ResponseEntity<Grouping> createGrouping(@RequestBody Grouping grouping) {
|
||||
Grouping created = groupingService.createGrouping(grouping);
|
||||
return ResponseEntity.ok(created);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取全部分组")
|
||||
@GetMapping
|
||||
public ResponseEntity<List<Grouping>> getAllGroupings() {
|
||||
List<Grouping> groupings = groupingService.getAllGroupings();
|
||||
return ResponseEntity.ok(groupings);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新分组名称")
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Grouping> updateGrouping(
|
||||
@PathVariable Long id,
|
||||
@RequestBody Grouping grouping) {
|
||||
grouping.setId(id);
|
||||
Grouping updated = groupingService.updateGrouping(grouping);
|
||||
return ResponseEntity.ok(updated);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除分组")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteGrouping(@PathVariable Long id) {
|
||||
groupingService.deleteGrouping(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user