评论

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

获取问题评论列表

GET /questions/:question/comments

参数

名称类型描述
limitInteger默认 20 ,获取列表条数,修正值 1 - 30
afterinteger默认 0 ,筛选偏移, 上一次获取的评论列表中最后一条的id

响应

Status: 200 OK
[
  {
    "id": 19,
    "user_id": 2,
    "target_user": 2,
    "reply_user": 0,
    "body": "这里是问题的评论",
    "commentable_id": 1,
    "commentable_type": "questions",
    "created_at": "2017-08-07 09:09:01",
    "updated_at": "2017-08-07 09:09:01"
  }
]
字段描述
id回答唯一标识 ID 。 $after参数的源
user_id发布评论用户标识ID
body评论的内容,markdown 。
commentable_id问题的id 。
commentable_type评论的对象 questions: 问题
reply_user被回复的用户
target_user问题发起者

获取回答评论列表

GET /question-answers/:answer/comments

参数

名称类型描述
limitInteger默认 20 ,获取列表条数,修正值 1 - 30
afterinteger默认 0 ,筛选偏移, 上一次获取的评论列表中最后一条的id

响应

Status: 200
[
  {
    "id": 22,
    "user_id": 2,
    "target_user": 1,
    "reply_user": 1,
    "body": "llllllllasdfasdfasdfasdf",
    "commentable_id": 1,
    "commentable_type": "question-answers",
    "created_at": "2017-08-07 09:43:08",
    "updated_at": "2017-08-07 09:43:08"
  }
]
字段描述
id回答唯一标识 ID 。 $after参数的源
user_id发布评论用户标识ID
body评论的内容,markdown 。
commentable_id问题的id 。
commentable_type评论的对象 questions: 问题
reply_user被回复的用户
target_user问题发起者

评论问题

POST /questions/:question/comments

输入

名称类型描述
bodyString必须,回答的内容,markdown。
reply_userinteger选填, 被回复用户的ID

响应

Status: 201 Created
{
  "message": [
    "操作成功"
  ],
  "comment": {
    "user_id": 2,
    "target_user": 2,
    "reply_user": 1,
    "body": "llllllllasdfasdfasdfasdf",
    "commentable_type": "questions",
    "commentable_id": 1,
    "updated_at": "2017-08-07 09:48:33",
    "created_at": "2017-08-07 09:48:33",
    "id": 23
  }
}

评论答案

POST /question-answers/:answer/comments

输入

名称类型描述
bodyString必须,回答的内容,markdown。
reply_userinteger选填, 被回复用户的ID

响应

Status: 201 Created
{
  "message": [
    "操作成功"
  ],
  "comment": {
    "user_id": 2,
    "target_user": 1,
    "reply_user": 1,
    "body": "llllllllasdfasdfasdfasdf",
    "commentable_type": "question-answers",
    "commentable_id": 1,
    "updated_at": "2017-08-07 09:55:50",
    "created_at": "2017-08-07 09:55:50",
    "id": 24
  }
}

删除问题评论

DELETE /questions/:question/comments/:answer

响应

Status: 204 No Content

删除回答评论

DELETE /question-answers/:answer/comments/:comment

响应

Status: 204 No Content