Skip to content

评论回复相关接口

获取评论回复

请求URL

  • /api/v1/comment/article/getComment?aid=文章ID&page=页码&pageSize=内容数量

请求方式

  • GET

返回示例

json
{
  "code": 200,
  "data": {
    "total": 1,
    "comments": [
      {
        "id": 1,
        "createdAt": "2022-06-20T13:42:40.625Z",
        "uid": 1,
        "content": "测试",
        "atUsernames": "",
        "atUserIds": "",
        "parentId": "",
        "replyCount": 2,
        "author": {
          "uid": 1,
          "name": "",
          "sign": "",
          "email": "",
          "phone": "",
          "avatar": "",
          "gender": 1,
          "spaceCover": "",
          "birthday": "",
          "createdAt": "",
        },
        "reply": [
          {
            "id": 1,
            "createdAt": "2022-06-20T13:42:40.625Z",
            "uid": 1,
            "content": "测试",
            "atUsernames": "",
            "atUserIds": "",
            "replyUserId": "",
            "replyUserName": "",
            "parentId": "",
            "author": {
              "uid": 1,
              "name": "",
              "sign": "",
              "email": "",
              "phone": "",
              "avatar": "",
              "gender": 1,
              "spaceCover": "",
              "birthday": "",
              "createdAt": "",
             },
          }
        ]
      }
    ]
  },
  "msg": "ok"
}

返回参数说明

参数名类型说明
totalint数量
commentsobject评论回复数组
评论comment
参数名类型说明
idint用户ID
createdAtstring发布时间
uidint用户ID
contentstring评论内容
atUsernamesstring@用户的用户名,使用,分隔
atUserIdsstring@用户的ID,使用,分隔 ,与atUsernames中的顺序一致
parentIdint所属评论ID
replyCountint回复数量
authorobject作者信息
replyobject回复数组
回复reply
参数名类型说明
idint用户ID
createdAtstring发布时间
uidint用户ID
contentstring评论内容
atUsernamesstring@用户的用户名,使用,分隔
atUserIdsstring@用户的ID,使用,分隔 ,与atUsernames中的顺序一致
replyUserNamestring回复用户的用户名
replyUserIdstring回复用户的ID
parentIdint所属评论ID
authorobject作者信息
作者信息author
参数名类型说明
uidint用户ID
namestring用户名
signstring个性签名
emailstring邮箱
phonestring手机号
avatarstring头像
genderint用户性别,0:未知;1:男;2:女
spacecoverstring用户空间封面图
birthdaytime生日
createdAttime注册时间

备注

该接口返回的total为评论和回复总数,而评论和回复是树结构的,因此返回的总数无法用于列表的分页

获取回复详情

请求URL
  • /api/v1/comment/article/getReply?commentId=评论ID&page=页码&pageSize=内容数量
请求方式
  • GET
返回示例
json
{
  "code": 200,
  "data": {
    "replies": [
      {
        "id": 1,
        "createdAt": "2022-06-20T13:42:40.625Z",
        "uid": 1,
        "content": "测试",
        "atUsernames": "",
        "atUserIds": "",
        "replyUserId": "",
        "replyUserName": "",
        "parentId": "",
        "author": {
          "uid": 1,
          "name": "",
          "sign": "",
          "email": "",
          "phone": "",
          "avatar": "",
          "gender": 1,
          "spaceCover": "",
          "birthday": "",
          "createdAt": "",
        },
      }
    ]
  },
  "msg": "ok"
}

返回参数说明

参数名类型说明
repliesobject回复数组
回复reply
参数名类型说明
idint用户ID
createdAtstring发布时间
uidint用户ID
contentstring评论内容
atUsernamesstring@用户的用户名,使用,分隔
atUserIdsstring@用户的ID,使用,分隔 ,与atUsernames中的顺序一致
replyUserNamestring回复用户的用户名
replyUserIdstring回复用户的ID
parentIdint所属评论ID
authorobject作者信息
作者信息author
参数名类型说明
uidint用户ID
namestring用户名
signstring个性签名
emailstring邮箱
phonestring手机号
avatarstring头像
genderint用户性别,0:未知;1:男;2:女
spacecoverstring用户空间封面图
birthdaytime生日
createdAttime注册时间

备注

发布评论回复

请求URL

  • /api/v1/comment/article/addComment

请求方式

  • POST

请求头

  • Authorization': token
  • "content-type": "application/json",

参数

参数名必选类型说明
cidint文章ID
contentstring评论内容
at[]string@的用户名数组
parentIDint所属评论ID
replyUserIDint回复用户的ID
replyUserNamestring回复用户的用户名
replyContentstring回复的评论或回复的内容,用于发送通知

返回示例

json
{
  "code": 200,
  "data": {
    "comment": {
      "id": 1,
      "createdAt": "2022-06-20T13:42:40.625Z",
      "uid": 1,
      "content": "测试",
      "atUsernames": "",
      "atUserIds": "",
      "replyUserId": "",
      "replyUserName": "",
      "parentId": "",
    }
  },
  "msg": "ok"
}

返回参数说明

参数名类型说明
idint用户ID
createdAtstring发布时间
uidint用户ID
contentstring评论内容
atUsernamesstring@用户的用户名,使用,分隔
atUserIdsstring@用户的ID,使用,分隔 ,与atUsernames中的顺序一致
replyUserNamestring回复用户的用户名
replyUserIdstring回复用户的ID
parentIdint所属评论ID
authorobject作者信息

备注

删除评论

请求URL

  • /api/v1/comment/article/deleteComment/评论或回复ID

请求方式

  • DELETE

请求头

  • Authorization': token
  • "content-type": "application/json",

返回示例

json
{
  "code": 200,
  "data": null,
  "msg":"ok"
}

备注

获取评论列表

请求URL

  • /api/v1/comment/article/getCommentList?aid=文章ID&page=页码&pageSize=内容数量

请求方式

  • GET

返回示例

json
{
  "code": 200,
  "data": {
    "total": 1,
    "comments": [
      {
        "id": 1,
        "cid": 1,
        "sid": 1,
        "uid": 1,
        "createdAt": "2022-06-20T13:42:40.625Z",
        "content": "测试",
        "targetReplyContent": "",
        "rootContent": "",    
        "commentId": 1,
        "parentId": "",
        "author": {
          "uid": 1,
          "name": "",
          "sign": "",
          "email": "",
          "phone": "",
          "avatar": "",
          "gender": 1,
          "spaceCover": "",
          "birthday": "",
          "createdAt": "",
        },
        "target": {
          "uid": 2,
          "name": "",
          "sign": "",
          "email": "",
          "phone": "",
          "avatar": "",
          "gender": 1,
          "spaceCover": "",
          "birthday": "",
          "createdAt": "",
        },
        "article": {
          "aid": 2,
          "uid": 2,
          "title": "测试1",
          "cover": "",
          "content": "",
          "status": 0,
          "copyright": true,
          "createdAt": "2021-07-16T08:49:54Z",
          "tags": "",
          "clicks": 10,
          "partitionId": 1,
          "author": {
            "uid": 1,
            "name": "",
            "sign": "",
            "email": "",
            "phone": "",
            "avatar": "",
            "gender": 1,
            "spaceCover": "",
            "birthday": "",
            "createdAt": "",
          },
        },
      }
    ]
  },
  "msg": "ok"
}

返回参数说明

参数名类型说明
totalint数量
commentsobject评论回复数组
评论comment
参数名类型说明
idintid
cidint文章ID
sidint发送用户ID
uidint用户ID
createdAtstring发布时间
contentstring评论或回复内容
targetReplyContentstring回复目标内容
rootContentstring根评论内容
commentIdint评论ID
authorobject作者信息
targetobject回复目标用户信息
articleobject文章信息
作者信息author
参数名类型说明
uidint用户ID
namestring用户名
signstring个性签名
emailstring邮箱
phonestring手机号
avatarstring头像
genderint用户性别,0:未知;1:男;2:女
spacecoverstring用户空间封面图
birthdaytime生日
createdAttime注册时间
文章信息
参数名类型说明
aidint文章ID
uidint用户ID
titlestring标题
coverstring封面图url
contentstring内容
statusint文章审核状态
copyrightbool是否为原创文章
clicksint文章点击量
createdAtstring上传时间
tagsstring文章标签
partitionIdint分区ID
authorobject作者信息

备注

根据 MIT 许可证发布