更新栏目

基本信息

接口名称: 更新栏目

接口类型: 数据更新

接口说明: 在某个站点内更新一个栏目

详细信息

URL

https://www.baklib.com/api/v1/channels/:id

完整URL示例

https://www.baklib.com/api/v1/channels/8725decb-9160-4f0a-9889-1046d38e755a

HTTP请求方式

PUT

授权认证方式

默认方式,需要添加请求header

Authorization: Bearer <token>

请求参数

参数 必选 类型及范围 说明
tenant_id true String 站点id
id true String 栏目id
name false String 栏目标题
description false String 描述
icon_name false String 图标
access_level false Integer 访问等级
status false Integer 栏目状态 0: 草稿,1: 发布
parent_id false String 父级栏目
identifier false String 栏目唯一标识
ordinal_type false String 排序方式
password false String 访问密码
channel_template false String 栏目模板
article_template false String 文章模板

示例代码

var data = JSON.stringify({
  "tenant_id": "aaa24dbe-a17b-4439-911d-176e0149cf76",
  "identifier": "xiaohui5",
  "name": "baba",
  "status": 1,
  "kind": 2,
  "icon_name": "fa fa-apple",
  "article_template": "article.theme_preview",
  "password": "1"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://www.baklib.com/api/v1/channels/8725decb-9160-4f0a-9889-1046d38e755a");
xhr.setRequestHeader("Authorization", "Bearer 8486df9cb8a93ea843702141065c4a8b714602b45e7c4a6bb26a26ea3d69de6");
xhr.setRequestHeader("Content-Type", "application/json");


xhr.send(data);

返回结果

{
    "code": 0,
    "status": "success",
    "message": {
        "id": "8725decb-9160-4f0a-9889-1046d38e755a",
        "parent_id": "38a4383f-9249-44b7-8531-6c9c35529aac",
        "name": "baba",
        "identifier": "xiaohui5",
        "description": "",
        "ordinal": 0,
        "status": 1,
        "status_name": "发布",
        "kind": 1,
        "kind_name": "栏目",
        "slug": "xiaohui5",
        "tenant_id": "aaa24dbe-a17b-4439-911d-176e0149cf76",
        "visits_count": 0,
        "created_at": "2022-11-07T17:24:16.952+08:00",
        "updated_at": "2022-11-18T11:34:46.540+08:00",
        "created_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
        "updated_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
        "password": "1",
        "access_level": 0,
        "variables": {},
        "variables_description": [],
        "frontend_url": "XXX",
        "ordinal_type": 3,
        "icon_name": "fa fa-apple",
        "channel_template": "channel.default",
        "article_template": "article.theme_preview",
        "edit_url": "XXX"
    }
}

返回字段说明

返回值字段 字段类型 说明
code Integer 状态码
status String 返回状态
message Hash 数据
        id String 栏目id
        parent_id String 父级栏目id
        name String 栏目名称
        identifier String 栏目唯一标识符
        description String 描述
        ordinal Integer 次序
        status Integer 栏目状态
        status_name String 栏目状态中文名称
        kind Integer 栏目种类
        kind_name String 栏目种类中文名称
        slug String 路径
        tenant_id String 站点id
        created_at Datetime 创建时间
        updated_at Datetime 更新时间
        created_by String 创建者id
        updated_by String 更新者id
        password String 密码
        access_level Integer 访问等级
        variables Jsonb 其他变量
        variables_description Array[String] 变量描述
        frontend_url String 前端访问地址
        ordinal_type String 排序种类
        icon_name String 图标
        channel_template String 栏目模板
        article_template String 文章模板
        edit_url String 编辑地址
2022-11-18
0 0