CommentMapper.java 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. package cn.seecoder.fdroidrepository.Mapper;
  2. import cn.seecoder.fdroidrepository.DataObject.Comment;
  3. import cn.seecoder.fdroidrepository.Service.CommentService;
  4. import org.apache.ibatis.annotations.*;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.HttpStatus;
  7. import org.springframework.http.ResponseEntity;
  8. import org.springframework.web.bind.annotation.*;
  9. import java.util.List;
  10. @Mapper
  11. public interface CommentMapper {
  12. @Select("SELECT * FROM comments WHERE post_id = #{postId}")
  13. @Results({
  14. @Result(property = "commentId", column = "comment_id"),
  15. @Result(property = "postId", column = "post_id"),
  16. @Result(property = "userId", column = "user_id"),
  17. @Result(property = "content", column = "content"),
  18. @Result(property = "createdAt", column = "created_at")
  19. })
  20. List<Comment> findByPostId(Long postId);
  21. @Insert("INSERT INTO comments (post_id, user_id, content, created_at) " +
  22. "VALUES (#{postId}, #{userId}, #{content}, #{createdAt})")
  23. void save(Comment comment);
  24. }