API 参考
本页只列核心 API。完整路由以 server/app/*/route/ 为准,系统内置 OpenAPI 可通过租户后台的 API 文档入口查看。
通用约定
- Content-Type:
application/json - 认证:
Authorization: Bearer <token> - 国际化:
Accept-Language: zh-CN - 平台端前缀:
/platformapi - 租户后台前缀:
/tenantapi - 公共前台前缀:
/api
响应格式:
json
{
"code": 200,
"message": "操作成功",
"data": {},
"timestamp": 1710529800
}分页格式通常为:
json
{
"code": 200,
"data": {
"list": [],
"pagination": {
"current_page": 1,
"per_page": 20,
"total": 100,
"last_page": 5
}
}
}错误码
| Code | 说明 |
|---|---|
| 200 | 成功 |
| 400 | 参数错误 |
| 401 | 未认证或 Token 过期 |
| 402 | 租户过期宽限期内写操作被拦截 |
| 403 | 权限不足、功能未开通或插件未授权 |
| 404 | 资源不存在 |
| 409 | 状态冲突,例如插件状态不可安装 |
| 422 | 表单或 manifest 校验失败 |
| 500 | 服务器错误 |
平台端 API
认证
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/auth/captcha | 登录验证码 |
| POST | /platformapi/auth/login | 平台管理员登录 |
| GET | /platformapi/auth/me | 当前管理员 |
| GET | /platformapi/auth/info | 当前管理员、菜单、权限 |
| POST | /platformapi/auth/refresh | 刷新 Token |
| POST | /platformapi/auth/logout | 退出登录 |
租户管理
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/tenants | 租户列表 |
| POST | /platformapi/tenants | 创建租户 |
| GET | /platformapi/tenants/:id | 租户详情 |
| PUT | /platformapi/tenants/:id | 更新租户 |
| DELETE | /platformapi/tenants/:id | 删除租户 |
| GET | /platformapi/tenants/:tenant_id/admins | 租户管理员列表 |
| PUT | /platformapi/tenants/:tenant_id/reset-password | 重置租户管理员密码 |
套餐和插件授权
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/plans | 套餐列表 |
| GET | /platformapi/plans/options | 套餐选项 |
| POST | /platformapi/plans | 创建套餐 |
| GET | /platformapi/plans/:id | 套餐详情 |
| PUT | /platformapi/plans/:id | 更新套餐 |
| DELETE | /platformapi/plans/:id | 删除套餐 |
| GET | /platformapi/plans/:planId/plugin-grants | 套餐插件授权 |
| PUT | /platformapi/plans/:planId/plugin-grants | 同步套餐插件授权 |
插件管理
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/plugins | 插件列表 |
| GET | /platformapi/plugins/options | 插件选项 |
| GET | /platformapi/plugins/:id | 插件详情 |
| POST | /platformapi/plugins/upload | 上传插件 zip |
| POST | /platformapi/plugins/install-from-disk | 登记内置插件 |
| POST | /platformapi/plugins/:id/install | 安装插件 |
| POST | /platformapi/plugins/:id/uninstall | 卸载插件 |
| POST | /platformapi/plugins/:id/upgrade | 升级插件 |
| DELETE | /platformapi/plugins/:id/data?force=true | 清理插件数据 |
插件前端构建
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/plugin-builds | 构建任务列表 |
| GET | /platformapi/plugin-builds/:id | 构建任务详情 |
| POST | /platformapi/plugin-builds/rebuild | 重建 platform 或 tenant 前端 |
订单和退款
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/orders | SaaS 订单列表 |
| GET | /platformapi/orders/:id | SaaS 订单详情 |
| POST | /platformapi/orders/:id/mark-paid | 线下收款后标记已支付 |
| POST | /platformapi/orders/:id/cancel | 取消待支付订单 |
| GET | /platformapi/refund | 退款记录列表 |
| GET | /platformapi/refund/:id | 退款详情 |
| POST | /platformapi/orders/:orderId/refund | 发起或标记退款 |
平台系统
平台系统管理使用单数资源名:
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /platformapi/system/admin | 平台管理员列表 |
| GET | /platformapi/system/role | 平台角色列表 |
| GET | /platformapi/system/menu | 平台菜单列表 |
| GET | /platformapi/system/log/login | 登录日志 |
| GET | /platformapi/system/log/operation | 操作日志 |
| POST | /platformapi/system/config/clear-cache | 清除配置缓存 |
| GET | /platformapi/system/generator/tables | 代码生成器表列表 |
租户端 API
认证
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /tenantapi/auth/captcha | 登录验证码 |
| POST | /tenantapi/auth/login | 租户管理员登录 |
| GET | /tenantapi/auth/info | 当前管理员、菜单、权限、SaaS 信息 |
| POST | /tenantapi/auth/refresh | 刷新 Token |
| POST | /tenantapi/auth/logout | 退出登录 |
订阅
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /tenantapi/subscription/current | 当前订阅状态 |
| GET | /tenantapi/subscription/plans | 可用套餐列表 |
| POST | /tenantapi/subscription/create-order | 创建订阅订单 |
| POST | /tenantapi/subscription/pay | 发起支付 |
| GET | /tenantapi/subscription/query-order?id=1 | 查询订单状态 |
插件应用
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /tenantapi/plugin | 当前租户可见插件列表 |
| POST | /tenantapi/plugin/:id/enable | 启用插件 |
| POST | /tenantapi/plugin/:id/disable | 禁用插件 |
| GET | /tenantapi/plugin/:pluginCode/config | 插件配置 |
| PUT | /tenantapi/plugin/:pluginCode/config | 保存插件配置 |
| GET | /tenantapi/plugin/:code/config-schema | 插件配置表单 schema |
| POST | /tenantapi/plugin/:id/purchase | 单独购买插件 |
移动端配置和构建
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /tenantapi/mobile/config | 当前租户移动端配置 |
| PUT | /tenantapi/mobile/config | 保存移动端配置 |
| GET | /tenantapi/mobile/config/eligible | 可作为首页或 TabBar 的插件页面 |
| GET | /tenantapi/mobile/builds | 移动端构建列表 |
| POST | /tenantapi/mobile/builds | 创建构建任务 |
| GET | /tenantapi/mobile/builds/:id | 构建详情 |
| POST | /tenantapi/mobile/builds/:id/release | 发布构建 |
| POST | /tenantapi/mobile/builds/:id/upload | 上传到目标平台 |
| PUT | /tenantapi/mobile/config/wechat-key | 保存微信小程序上传密钥 |
| DELETE | /tenantapi/mobile/config/wechat-key | 清除微信小程序上传密钥 |
系统和业务
常用前缀:
/tenantapi/system/admin— 租户管理员/tenantapi/system/role— 角色/tenantapi/system/menu— 菜单/tenantapi/system/permission— 权限只读树/tenantapi/system/dictionary— 字典/tenantapi/system/file— 文件管理/tenantapi/system/config— 租户系统配置/tenantapi/article、/tenantapi/article-category— 文章内容/tenantapi/announcement、/tenantapi/agreement、/tenantapi/feedback— 内容和反馈/tenantapi/message/*— 消息模板、事件、日志/tenantapi/wechat/*— 微信公众号相关能力/tenantapi/upload/*— 文件上传
公共 API
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /api/saas/notify/wechat | SaaS 微信支付回调 |
| POST | /api/saas/notify/alipay | SaaS 支付宝回调 |
| GET | /api/mobile/config | 移动端运行时配置 |
| GET | /api/article/list | 公共文章列表 |
| GET | /api/article/detail/:id | 公共文章详情 |
