评论

优质
小牛编辑
133浏览
2023-12-01

评论一条资讯

POST /news/{news}/comments

参数

名称描述
body评论内容
reply_user被回复用户id 默认为0

Response

Headers

Status: 201 Created
{
  "message": [
    "操作成功"
  ],
  "comment": {
    "user_id": 1,
    "reply_user": 0,
    "target_user": 1,
    "body": "baishi",
    "commentable_type": "news",
    "commentable_id": 2,
    "updated_at": "2017-08-10 09:31:58",
    "created_at": "2017-08-10 09:31:58",
    "id": 5
  }
}
名称描述
message消息
comment评论信息
comment.id评论id
comment.user_id评论者id
comment.target_user资讯发布者id
comment.reply_user被回复者id
comment.body评论内容

获取一条资讯的评论列表

GET /news/{news}/comments

参数

名称类型必须说明
limitint-数据返回条数
afterint-数据翻页标识

Response

Headers

Status: 200 OK
{
  "pinneds": [],
  "comments": [
    {
      "id": 2389,
      "user_id": 215,
      "target_user": 0,
      "reply_user": 0,
      "created_at": "2017-07-12 01:13:45",
      "updated_at": "2017-07-12 01:13:45",
      "commentable_type": "news",
      "commentable_id": 31,
      "body": "而且其实我想把这篇资讯分享到我的动态,然而……"
    },
    {
      "id": 2388,
      "user_id": 215,
      "target_user": 0,
      "reply_user": 0,
      "created_at": "2017-07-12 01:13:01",
      "updated_at": "2017-07-12 01:13:01",
      "commentable_type": "news",
      "commentable_id": 31,
      "body": "我下拉到底部后,评论编辑窗口不见了……,"
    }
  ]
}

返回参数

名称描述
pinneds置顶评论
comments评论列表
id评论id
user_id评论者id
target_user资讯发布者id
reply_user被回复者id
body评论内容

删除一条资讯评论

DELETE /news/{news}/comments/{comment}

Response

Headers

Status: 204 No Content