|
|
@@ -0,0 +1,34 @@
|
|
|
+package cn.seecoder.fdroidrepository.Mapper;
|
|
|
+
|
|
|
+import cn.seecoder.fdroidrepository.DataObject.Comment;
|
|
|
+import cn.seecoder.fdroidrepository.Service.CommentService;
|
|
|
+import org.apache.ibatis.annotations.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+// CommentController.java
|
|
|
+// CommentMapper.java
|
|
|
+@Mapper
|
|
|
+public interface CommentMapper {
|
|
|
+
|
|
|
+ @Select("SELECT * FROM comments WHERE post_id = #{postId}")
|
|
|
+ @Results({
|
|
|
+ @Result(property = "commentId", column = "comment_id"),
|
|
|
+ @Result(property = "postId", column = "post_id"),
|
|
|
+ @Result(property = "userId", column = "user_id"),
|
|
|
+ @Result(property = "content", column = "content"),
|
|
|
+ @Result(property = "createdAt", column = "created_at")
|
|
|
+ // 添加其他属性映射关系
|
|
|
+ })
|
|
|
+ List<Comment> findByPostId(Long postId);
|
|
|
+
|
|
|
+ @Insert("INSERT INTO comments (post_id, user_id, content, created_at) " +
|
|
|
+ "VALUES (#{postId}, #{userId}, #{content}, #{createdAt})")
|
|
|
+ void save(Comment comment);
|
|
|
+}
|
|
|
+
|
|
|
+
|