后台管理(表/数据/token/管理员) ( admin ) 相关文档
表列表 ✅
请求地址:GET /admin/tables
参数:无参数
使用示例:
javascript
// 表列表 - /admin/tables
input = {};
output = {
"success": true,
"data": [
{
"id": 1,
"name": "users",
"label": "用户",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "age",
"label": "age",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": null,
"createdAt": 1783640695280,
"updatedAt": 1783640695280
}
]
};表详情 ✅
请求地址:GET /admin/tables/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
使用示例:
javascript
// 表详情 - /admin/tables/1
input = {};
output = {
"success": true,
"data": {
"id": 1,
"name": "users",
"label": "用户",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "age",
"label": "age",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": null,
"createdAt": 1783640695280,
"updatedAt": 1783640695280
}
};导入已有表 ✅
请求地址:POST /admin/tables/import
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
name | body | string | 否 | 是 | (无) |
使用示例:
javascript
// 导入已有表 - /admin/tables/import
input = {
"name": "posts"
};
output = {
"success": true,
"data": {
"id": 2,
"name": "posts",
"label": "",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "title",
"label": "title",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": null,
"createdAt": 1783640695304,
"updatedAt": 1783640695304
}
};新建模型 ✅
请求地址:POST /admin/tables
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
name | body | string | 否 | 是 | (无) |
label | body | string | 否 | 是 | (无) |
fields | body | array | 否 | 是 | (无) |
note | body | string | 否 | 否 | (无) |
autoTimestamps | body | boolean | 否 | 否 | (无) |
使用示例:
javascript
// 新建模型 - /admin/tables
input = {
"name": "users",
"label": "用户",
"fields": [
{
"name": "id",
"jsonType": "integer",
"isPrimary": true,
"isAutoIncrement": true
},
{
"name": "name",
"jsonType": "string"
},
{
"name": "age",
"jsonType": "integer"
}
]
};
output = {
"success": true,
"data": {
"id": 1,
"name": "users",
"label": "用户",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "age",
"label": "age",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": null,
"createdAt": 1783640695280,
"updatedAt": 1783640695280
}
};更新元数据 ✅
请求地址:PUT /admin/tables/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
label | body | string | 否 | 否 | (无) |
note | body | string | 否 | 否 | (无) |
isPublished | body | boolean | 否 | 否 | (无) |
isEditable | body | boolean | 否 | 否 | (无) |
使用示例:
javascript
// 更新元数据 - /admin/tables/1
input = {
"label": "用户表",
"note": "用户信息表",
"isPublished": true
};
output = {
"success": true,
"data": {
"id": 1,
"name": "users",
"label": "用户表",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "age",
"label": "age",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": "用户信息表",
"createdAt": 1783640695280,
"updatedAt": 1783640695295
}
};刷新表结构 ✅
请求地址:POST /admin/tables/:id/refresh
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
使用示例:
javascript
// 刷新表结构 - /admin/tables/1/refresh
input = {};
output = {
"success": true,
"data": {
"id": 1,
"name": "users",
"label": "用户表",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "age",
"label": "age",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": "用户信息表",
"createdAt": 1783640695280,
"updatedAt": 1783640695299
}
};取消注册 ✅
请求地址:DELETE /admin/tables/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
confirm | query | boolean | 否 | 是 | (无) |
使用示例:
javascript
// 取消注册(导入表) - /admin/tables/2?confirm=true
input = {
"confirm": true
};
output = {
"success": true,
"data": {
"success": true
}
};
// 取消注册表 - /admin/tables/1?confirm=true
input = {
"confirm": true
};
output = {
"success": true,
"data": {
"success": true
}
};数据列表 ✅
请求地址:GET /admin/tables/:id/data
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
page | query | number | 否 | 否 | (无) |
size | query | number | 否 | 否 | (无) |
order | query | string | 否 | 否 | (无) |
q | query | string | 否 | 否 | (无) |
使用示例:
javascript
// 数据列表 - /admin/tables/1/data?page=1&size=20
input = {};
output = {
"success": true,
"data": {
"rows": [
{
"id": 1,
"name": "alice",
"age": 30
}
],
"total": 1,
"page": 1,
"size": 20
}
};导出 CSV ✅
请求地址:GET /admin/tables/:id/export
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
page | query | number | 否 | 否 | (无) |
size | query | number | 否 | 否 | (无) |
order | query | string | 否 | 否 | (无) |
q | query | string | 否 | 否 | (无) |
单条 ✅
请求地址:GET /admin/tables/:id/data/:pk
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
pk | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 单条记录 - /admin/tables/1/data/1
input = {};
output = {
"success": true,
"data": {
"id": 1,
"name": "alice",
"age": 30
}
};新增 ✅
请求地址:POST /admin/tables/:id/data
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
使用示例:
javascript
// 新增记录 - /admin/tables/1/data
input = {
"name": "alice",
"age": 30
};
output = {
"success": true,
"data": {
"id": 1,
"name": "alice",
"age": 30
}
};修改 ✅
请求地址:PUT /admin/tables/:id/data/:pk
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
pk | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 修改记录 - /admin/tables/1/data/1
input = {
"age": 31
};
output = {
"success": true,
"data": {
"success": true
}
};删除 ✅
请求地址:DELETE /admin/tables/:id/data/:pk
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
pk | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 删除记录 - /admin/tables/1/data/1
input = {};
output = {
"success": true,
"data": {
"success": true
}
};Token 列表 ✅
请求地址:GET /admin/tokens
参数:无参数
使用示例:
javascript
// Token 列表 - /admin/tokens
input = {};
output = {
"success": true,
"data": [
{
"id": 1,
"name": "前端读写",
"token_prefix": "oa_64cae****",
"permissions": {
"tables": [
"*"
],
"actions": [
"read",
"write"
]
},
"is_active": true,
"expires_at": null,
"last_used_at": null,
"created_at": 1783640695315,
"updated_at": 1783640695315
}
]
};创建 Token ✅
请求地址:POST /admin/tokens
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
name | body | string | 否 | 是 | (无) |
permissions | body | object | 否 | 是 | (无) |
使用示例:
javascript
// 创建 Token - /admin/tokens
input = {
"name": "前端读写",
"permissions": {
"tables": [
"*"
],
"actions": [
"read",
"write"
]
}
};
output = {
"success": true,
"data": {
"id": 1,
"name": "前端读写",
"token": "oa_64cae66d23697d58929f8d70a7bd0d04aca88a9d9d5847459d9a53ddfafbb30c",
"tokenPrefix": "oa_64cae****",
"permissions": {
"tables": [
"*"
],
"actions": [
"read",
"write"
]
}
}
};更新 Token ✅
请求地址:PUT /admin/tokens/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
name | body | string | 否 | 否 | (无) |
permissions | body | object | 否 | 否 | (无) |
isActive | body | boolean | 否 | 否 | (无) |
expiresAt | body | number | 否 | 否 | (无) |
使用示例:
javascript
// 更新 Token - /admin/tokens/1
input = {
"name": "前端读写(已停用)",
"isActive": false
};
output = {
"success": true,
"data": {
"success": true
}
};删除 Token ✅
请求地址:DELETE /admin/tokens/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
使用示例:
javascript
// 删除 Token - /admin/tokens/1
input = {};
output = {
"success": true,
"data": {
"success": true
}
};管理员列表 ✅
请求地址:GET /admin/admins
参数:无参数
使用示例:
javascript
// 管理员列表 - /admin/admins
input = {};
output = {
"success": true,
"data": [
{
"id": 1,
"name": "admin",
"nickname": "admin",
"must_change_password": 0,
"created_at": 1783640694759,
"updated_at": 1783640695205
},
{
"id": 2,
"name": "ops",
"nickname": "运维",
"must_change_password": 1,
"created_at": 1783640695387,
"updated_at": 1783640695387
}
]
};新建管理员 ✅
请求地址:POST /admin/admins
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
name | body | string | 否 | 是 | (无) |
nickname | body | string | 否 | 是 | (无) |
password | body | string | 否 | 是 | (无) |
使用示例:
javascript
// 新建管理员 - /admin/admins
input = {
"name": "ops",
"nickname": "运维",
"password": "init123"
};
output = {
"success": true,
"data": {
"id": 2,
"name": "ops",
"nickname": "运维",
"must_change_password": 1,
"created_at": 1783640695387,
"updated_at": 1783640695387
}
};更新管理员 ✅
请求地址:PUT /admin/admins/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
nickname | body | string | 否 | 否 | (无) |
password | body | string | 否 | 否 | (无) |
使用示例:
javascript
// 更新管理员 - /admin/admins/2
input = {
"nickname": "运维同学"
};
output = {
"success": true,
"data": {
"success": true
}
};删除管理员 ✅
请求地址:DELETE /admin/admins/:id
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
id | params | number | 否 | 是 | (无) |
使用示例:
javascript
// 删除管理员 - /admin/admins/2
input = {};
output = {
"success": true,
"data": {
"success": true
}
};