最后更新时间:2026-09-22 18:41:44
外部栏目 API 路径位于 /api/api_column_*,使用 Authorization: Bearer 鉴权,且要求该用户具备管理员权限。它们与后台管理接口共用同一批 service handler,因此写入操作同样会写入事件日志(model 记为 api)。
GET /api/api_column_list
Authorization: Bearer YOUR_USER_TOKENcurl 示例:
curl -X GET "http://127.0.0.1:8000/api/api_column_list" \
-H "Authorization: Bearer YOUR_USER_TOKEN"成功时 data 为栏目数组,包含 id、pid、name、title、slug、status、ext、content_count 等字段。
GET /api/api_column_get?id=1
Authorization: Bearer YOUR_USER_TOKENcurl -X GET "http://127.0.0.1:8000/api/api_column_get?id=1" \
-H "Authorization: Bearer YOUR_USER_TOKEN"POST /api/api_column_create
Content-Type: application/json
Authorization: Bearer YOUR_USER_TOKEN请求体:
{
"pid": 0,
"name": "产品栏目",
"title": "产品中心",
"description": "栏目描述",
"keywords": "产品,设备",
"slug": "products",
"kind": 1,
"status": 1,
"link_url": "",
"link_target": "_self",
"img": "",
"template": "",
"c_template": "",
"limit_num": 10,
"sort": 0,
"inherit": 0,
"ext": "",
"content": ""
}pid:父栏目 ID,根栏目使用 0。name:栏目名称,必填。title:栏目标题。slug:栏目 URL 标识,必填且不能重复。kind:栏目类型,常用 1 文章栏目、2 产品栏目、3 单页栏目。status:栏目状态,通常 1 启用、0 禁用。ext:扩展字段,按当前接口模型传入 JSON 字符串。curl -X POST "http://127.0.0.1:8000/api/api_column_create" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_USER_TOKEN" \
-d '{
"name": "产品栏目",
"title": "产品中心",
"slug": "products",
"pid": 0,
"kind": 1,
"status": 1,
"link_target": "_self",
"limit_num": 10
}'成功返回新建栏目的 ID,后续更新、删除直接用这个 id:
{
"code": 200,
"msg": "ok",
"data": {
"id": 42
}
}POST /api/api_column_update
Content-Type: application/json
Authorization: Bearer YOUR_USER_TOKEN请求体使用创建字段,并增加必填的 id:
{
"id": 1,
"name": "产品栏目",
"title": "更新后的产品中心",
"description": "更新后的描述",
"slug": "products",
"status": 1,
"kind": 1,
"pid": 0,
"sort": 1
}栏目必须为空,不能包含内容或子栏目。删除前请先迁移或删除栏目下的内容。
POST /api/api_column_delete
Content-Type: application/json
Authorization: Bearer YOUR_USER_TOKEN请求体:
{
"id": 1
}curl -X POST "http://127.0.0.1:8000/api/api_column_delete" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_USER_TOKEN" \
-d '{"id":1}'