Article:update

注意:该接口需要登陆后才能调用。

管理员可修改文章。文章作者是否可修改文章,由管理员在后台的设置决定。

content_markdowncontent_rendered 两个参数仅传入其中一个即可, 若两个参数都传入,则以 content_markdown 为准。

HTTP 请求

PATCH /api/articles/{article_id}

参数

参数名参数位置类型默认值说明
article_idpathinteger

文章ID

includequerystring

响应中需要包含的关联数据,用 , 分隔。可以为 user, topics, is_following, voting

请求体

请求体类型:application/json

示例

{
  "title": "欢迎使用 MDClub 开源社区系统",
  "topic_ids": [ 1, 2, 3 ],
  "content_markdown": "MDClub 是一个开源社区系统,使用 [mdui](https://mdui.org) 作为前端框架。

系统的所有功能都通过 Restful Api 开放,共提供了超过 200 个接口。你可以使用这些接口开发任意客户端。
",
  "content_rendered": "<p>MDClub 是一个开源社区系统,使用 <a href="https://mdui.org" target="_blank">mdui</a> 作为前端框架。</p><p>系统的所有功能都通过 Restful Api 开放,共提供了超过 200 个接口。你可以使用这些接口开发任意客户端。</p>"
}

参数说明

参数名必选类型说明
titlestring

标题

topic_idsarray
content_markdownstring

Markdown 格式的正文

content_renderedstring

HTML 格式的正文

响应

文章详情

示例

{
  "code": 0,
  "data": {
    "article_id": 1,
    "user_id": 1,
    "title": "欢迎使用 MDClub 开源社区系统",
    "content_markdown": "MDClub 是一个开源社区系统,使用 [mdui](https://mdui.org) 作为前端框架。

系统的所有功能都通过 Restful Api 开放,共提供了超过 200 个接口。你可以使用这些接口开发任意客户端。
",
    "content_rendered": "<p>MDClub 是一个开源社区系统,使用 <a href="https://mdui.org" target="_blank">mdui</a> 作为前端框架。</p><p>系统的所有功能都通过 Restful Api 开放,共提供了超过 200 个接口。你可以使用这些接口开发任意客户端。</p>",
    "comment_count": 22,
    "follower_count": 12,
    "vote_count": 44,
    "vote_up_count": 96,
    "vote_down_count": 52,
    "create_time": 1563512214,
    "update_time": 1563512214,
    "delete_time": 0,
    "relationships": {
      "user": {
        "user_id": 1,
        "username": "zdhxiong",
        "headline": "mdui作者",
        "avatar": {
          "original": "https://mdclub.org/user-avatar/c4/ca/bc03445db47540eea79148252e7a91fe.jpg",
          "small": "https://mdclub.org/user-avatar/c4/ca/bc03445db47540eea79148252e7a91fe_small.jpg",
          "middle": "https://mdclub.org/user-avatar/c4/ca/bc03445db47540eea79148252e7a91fe_middle.jpg",
          "large": "https://mdclub.org/user-avatar/c4/ca/bc03445db47540eea79148252e7a91fe_large.jpg"
        }
      },
      "topics": [
        {
          "topic_id": 1,
          "name": "MDClub",
          "cover": {
            "original": "https://mdclub.org/topic-cover/c4/ca/bc03445db47540eea79148252e7a91fe.jpg",
            "small": "https://mdclub.org/topic-cover/c4/ca/bc03445db47540eea79148252e7a91fe_small.jpg",
            "middle": "https://mdclub.org/topic-cover/c4/ca/bc03445db47540eea79148252e7a91fe_middle.jpg",
            "large": "https://mdclub.org/topic-cover/c4/ca/bc03445db47540eea79148252e7a91fe_large.jpg"
          }
        }
      ],
      "is_following": true,
      "voting": "up"
    }
  }
}

参数说明

参数名 类型 说明
code integer

无任何错误时,状态码为 0

data.article_id integer

文章ID

data.user_id integer

用户ID

data.title string

文章标题

data.content_markdown string

Markdown 格式的文章内容

data.content_rendered string

HTML 格式的文章内容

data.comment_count integer

评论数量

data.follower_count integer

关注者数量

data.vote_count integer

投票数(赞成票 - 反对票,可能为负数)

data.vote_up_count integer

赞成票总数

data.vote_down_count integer

反对票总数

data.create_time integer

创建时间

data.update_time integer

更新时间(用户可以更新自己的文章)

data.delete_time integer

🔐删除时间

data.relationships.user.user_id integer

用户ID

data.relationships.user.username string

用户名

data.relationships.user.headline string

一句话介绍

data.relationships.user.avatar.original string

头像原图地址

data.relationships.user.avatar.small string

小头像地址

data.relationships.user.avatar.middle string

中头像地址

data.relationships.user.avatar.large string

大头像地址

data.relationships.topics[].topic_id integer

话题 ID

data.relationships.topics[].name string

话题名称

data.relationships.topics[].cover.original string

封面原图地址

data.relationships.topics[].cover.small string

小型封面地址

data.relationships.topics[].cover.middle string

中型封面地址

data.relationships.topics[].cover.large string

大型封面地址

data.relationships.is_following boolean

当前登录用户是否已关注该文章

data.relationships.voting string

当前登录用户的投票类型(updown),未投过票则为空字符串

取值范围包括:up, down,