创建栏目

基本信息

接口名称: 创建栏目

接口类型: 数据上传

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

详细信息

URL

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

完整URL示例

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

HTTP请求方式

POST

授权认证方式

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

Authorization: Bearer <token>

请求参数

参数 必选 类型及范围 说明
tenant_id true String 站点id
name true String 栏目标题
icon_name false String 图标
access_level false Integer 访问等级
description false String 描述
status false Integer 栏目状态,0=>草稿,1=>发布,默认为0
parent_id false String 父栏目id
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",
  "name": "测试1118"
});

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

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

xhr.open("POST", "https://www.baklib.com/api/v1/channels");
xhr.setRequestHeader("Authorization", "Bearer 8486df9cb8a93ea843702141065c4a8b714602b45e7c4a6bb26a26ea3d69de6");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);

返回结果

{
    "code": 0,
    "status": "success",
    "message": {
        "id": "905bf8ba-deeb-4401-84e8-e7d62bf6e4d2",
        "parent_id": "38a4383f-9249-44b7-8531-6c9c35529aac",
        "name": "测试1118",
        "identifier": "2b15",
        "description": null,
        "ordinal": 0,
        "status": 0,
        "status_name": "草稿",
        "kind": 1,
        "kind_name": "栏目",
        "slug": "2b15",
        "tenant_id": "aaa24dbe-a17b-4439-911d-176e0149cf76",
        "visits_count": 0,
        "created_at": "2022-11-14T18:32:27.193+08:00",
        "updated_at": "2022-11-14T18:32:27.166+08:00",
        "created_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
        "updated_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
        "password": null,
        "access_level": 0,
        "variables": {},
        "variables_description": [],
        "frontend_url": "XXX",
        "ordinal_type": 0,
        "icon_name": null,
        "channel_template": "channel.default",
        "article_template": "article.default",
        "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