commemt fix
Change-Id: I43d07c00de12649e25a4d925c59f3544b8d0b29d
diff --git a/src/main/java/com/example/g8backend/controller/CommentController.java b/src/main/java/com/example/g8backend/controller/CommentController.java
index 353a45d..8d61f23 100644
--- a/src/main/java/com/example/g8backend/controller/CommentController.java
+++ b/src/main/java/com/example/g8backend/controller/CommentController.java
@@ -1,8 +1,11 @@
package com.example.g8backend.controller;
+import com.example.g8backend.dto.ApiResponse;
+import com.example.g8backend.dto.CommentDTO;
import com.example.g8backend.entity.Comment;
import com.example.g8backend.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -14,11 +17,12 @@
@Autowired
private ICommentService commentService;
- // 创建评论
+
@PostMapping
- public void createComment(@RequestParam Long postId, @RequestParam Long userId,
- @RequestParam String content, @RequestParam(required = false) Long parentCommentId) {
- commentService.createComment(postId, userId, content, parentCommentId);
+ public ResponseEntity<ApiResponse<CommentDTO>> createComment(@RequestBody CommentDTO commentDTO) {
+ commentService.createComment(commentDTO);
+ ApiResponse<CommentDTO> response = ApiResponse.message("评论创建成功");
+ return ResponseEntity.ok(response);
}
// 获取某帖子下的所有评论,包括顶级评论及其子评论