forked from xiaohei/taiji-AI-PAD
更新jwt
This commit is contained in:
@@ -1310,17 +1310,114 @@ curl http://localhost:8001/tools?category=weather
|
||||
- GET `/user/agents/activity` — 最近执行记录列表。
|
||||
- GET `/user/resources/usage` — EU/CPU/内存消耗汇总。
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 仪表盘总览
|
||||
curl -X GET "http://localhost:8002/api/user/dashboard/stats"
|
||||
|
||||
# 最近执行记录
|
||||
curl -X GET "http://localhost:8002/api/user/agents/activity"
|
||||
|
||||
# 资源消耗汇总
|
||||
curl -X GET "http://localhost:8002/api/user/resources/usage"
|
||||
```
|
||||
|
||||
**响应示例**
|
||||
|
||||
```json
|
||||
{
|
||||
"activeAgents": 3,
|
||||
"totalRequests": 42,
|
||||
"euBalance": 1200,
|
||||
"systemHealth": 97
|
||||
}
|
||||
```
|
||||
|
||||
### 服务网关 (Service Gateway)
|
||||
- POST `/gateway/select` — 选择网关类型 MCP/A2A/API。
|
||||
- POST `/gateway/api/create` — 创建网关 API 记录(占位)。
|
||||
- GET `/gateway/apis` — API 列表。
|
||||
- GET `/gateway/monitoring` — 网关监控统计。
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 选择网关
|
||||
curl -X POST "http://localhost:8002/api/gateway/select" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"gatewayType":"MCP"}'
|
||||
|
||||
# 创建网关 API
|
||||
curl -X POST "http://localhost:8002/api/gateway/api/create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"demo-api","method":"json","content":"{\\"ping\\":true}"}'
|
||||
|
||||
# 获取列表
|
||||
curl -X GET "http://localhost:8002/api/gateway/apis"
|
||||
|
||||
# 监控数据
|
||||
curl -X GET "http://localhost:8002/api/gateway/monitoring"
|
||||
```
|
||||
|
||||
**创建返回示例**
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "a9d4...",
|
||||
"name": "demo-api",
|
||||
"method": "json",
|
||||
"content": "{\"ping\":true}",
|
||||
"createdAt": "2025-12-24T12:00:00.000000"
|
||||
}
|
||||
```
|
||||
|
||||
### 数据与工具 (Data & Tools)
|
||||
- POST `/tools/generate` — 基于入参生成 Tool 记录(落库)。
|
||||
- GET `/tools/list` — Tool 列表。
|
||||
- POST `/data-templates/create` — 创建数据模板占位。
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 生成 Tool
|
||||
curl -X POST "http://localhost:8002/api/tools/generate" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name":"weather-get",
|
||||
"description":"Get weather",
|
||||
"frameworkTemplate":"API",
|
||||
"gateway":"/gateway/weather",
|
||||
"config": {"location":{"type":"string"}},
|
||||
"maxScale": 100
|
||||
}'
|
||||
|
||||
# 工具列表
|
||||
curl -X GET "http://localhost:8002/api/tools/list"
|
||||
|
||||
# 创建数据模板
|
||||
curl -X POST "http://localhost:8002/api/data-templates/create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name":"orders-json",
|
||||
"type":"json_api",
|
||||
"config":{"apiUrl":"https://api.example.com/orders"}
|
||||
}'
|
||||
```
|
||||
|
||||
**工具返回示例**
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "0c2d...",
|
||||
"name": "weather-get",
|
||||
"description": "Get weather",
|
||||
"category": "api",
|
||||
"endpoint": "/gateway/weather",
|
||||
"createdAt": "2025-12-24T12:00:00.000000"
|
||||
}
|
||||
```
|
||||
|
||||
### 代理工厂与编排 (Agents / Workflows)
|
||||
- GET `/agents/platform` — 平台 Agent 列表。
|
||||
- POST `/agents/deploy` — 部署占位记录。
|
||||
@@ -1330,11 +1427,58 @@ curl http://localhost:8001/tools?category=weather
|
||||
- PUT `/workflows/{id}` — 更新工作流。
|
||||
- DELETE `/workflows/{id}` — 删除工作流。
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 平台 Agent 列表
|
||||
curl -X GET "http://localhost:8002/api/agents/platform"
|
||||
|
||||
# 部署 Agent
|
||||
curl -X POST "http://localhost:8002/api/agents/deploy" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"agentId":"<agent-id>","instances":2,"model":"gpt-4.1","gateway":"MCP"}'
|
||||
|
||||
# 已部署列表
|
||||
curl -X GET "http://localhost:8002/api/agents/deployed"
|
||||
|
||||
# 创建工作流
|
||||
curl -X POST "http://localhost:8002/api/workflows/create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name":"order-flow",
|
||||
"gateway":"MCP",
|
||||
"nodes":[{"agentId":"<agent-id>","agentType":"platform","agentName":"planner"}]
|
||||
}'
|
||||
|
||||
# 更新工作流
|
||||
curl -X PUT "http://localhost:8002/api/workflows/<id>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"order-flow-updated"}'
|
||||
|
||||
# 删除工作流
|
||||
curl -X DELETE "http://localhost:8002/api/workflows/<id>"
|
||||
```
|
||||
|
||||
### 计费 (Billing)
|
||||
- GET `/billing/balance` — EU 余额。
|
||||
- GET `/billing/history` — 计费历史。
|
||||
- POST `/billing/recharge` — 充值并追加记录。
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 余额
|
||||
curl -X GET "http://localhost:8002/api/billing/balance"
|
||||
|
||||
# 历史
|
||||
curl -X GET "http://localhost:8002/api/billing/history"
|
||||
|
||||
# 充值 100 EU
|
||||
curl -X POST "http://localhost:8002/api/billing/recharge" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"amount":100}'
|
||||
```
|
||||
|
||||
### 渠道合作伙伴 (Channel Partner)
|
||||
- POST `/channel/auth/login`
|
||||
- GET `/channel/dashboard/stats`
|
||||
@@ -1351,6 +1495,34 @@ curl http://localhost:8001/tools?category=weather
|
||||
- POST `/channel/admins/create`
|
||||
- PUT `/channel/admins/{id}/permissions`
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 登录
|
||||
curl -X POST "http://localhost:8002/api/channel/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email":"ops@demo.com","password":"pass"}'
|
||||
|
||||
# 概览
|
||||
curl -X GET "http://localhost:8002/api/channel/dashboard/stats"
|
||||
|
||||
# 租户列表
|
||||
curl -X GET "http://localhost:8002/api/channel/tenants"
|
||||
|
||||
# 创建租户
|
||||
curl -X POST "http://localhost:8002/api/channel/tenants/create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"tenant-a","subscriptionTier":"pro","discount":10}'
|
||||
|
||||
# 分配资源
|
||||
curl -X PUT "http://localhost:8002/api/channel/tenants/<id>/resources" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"agents":[{"agentId":"<agent-id>","quantity":5}]}'
|
||||
|
||||
# 计费统计
|
||||
curl -X GET "http://localhost:8002/api/channel/billing/stats"
|
||||
```
|
||||
|
||||
### 超级管理员 (Super Admin)
|
||||
- POST `/admin/auth/login`
|
||||
- GET `/admin/dashboard/stats`
|
||||
@@ -1371,12 +1543,57 @@ curl http://localhost:8001/tools?category=weather
|
||||
- GET `/admin/providers/stats`
|
||||
- GET `/admin/channels/backend/stats`
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 登录
|
||||
curl -X POST "http://localhost:8002/api/admin/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email":"admin@demo.com","password":"pass"}'
|
||||
|
||||
# 概览
|
||||
curl -X GET "http://localhost:8002/api/admin/dashboard/stats"
|
||||
|
||||
# 创建渠道
|
||||
curl -X POST "http://localhost:8002/api/admin/channels/create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"partner-a","email":"owner@partner.com","commissionRate":5}'
|
||||
|
||||
# 更新佣金
|
||||
curl -X PUT "http://localhost:8002/api/admin/channels/<id>/commission" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"commissionRate":8}'
|
||||
|
||||
# 资源模型列表
|
||||
curl -X GET "http://localhost:8002/api/admin/resources/models"
|
||||
```
|
||||
|
||||
### 供应商中心 (Provider Center)
|
||||
- POST `/providers/auth/login`
|
||||
- GET `/providers/models`
|
||||
- POST `/providers/models/add`
|
||||
- GET `/providers/data`
|
||||
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 登录
|
||||
curl -X POST "http://localhost:8002/api/providers/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email":"provider@demo.com","password":"pass"}'
|
||||
|
||||
# 模型列表
|
||||
curl -X GET "http://localhost:8002/api/providers/models"
|
||||
|
||||
# 新增模型
|
||||
curl -X POST "http://localhost:8002/api/providers/models/add" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"claude","apiUrl":"https://api.example.com","apiKey":"sk-demo","supportedModels":["claude-3"]}'
|
||||
|
||||
# 数据概览
|
||||
curl -X GET "http://localhost:8002/api/providers/data"
|
||||
```
|
||||
|
||||
**通用说明**
|
||||
- 所有接口均为 JSON 输入/输出,未启用鉴权,前端可直接联调。
|
||||
- 返回体为轻量占位数据,字段名与 BACKEND_INTEGRATION_CHECKLIST.md 对齐,后续可替换为真实实现。
|
||||
|
||||
@@ -44,10 +44,12 @@ def create_app() -> FastAPI:
|
||||
|
||||
async with AsyncSessionLocal() as session:
|
||||
principal = await authenticate_request(request, session)
|
||||
if request.url.path.startswith("/api") and principal is None:
|
||||
return JSONResponse({"detail": "Not authenticated"}, status_code=401)
|
||||
if principal:
|
||||
request.state.principal = principal
|
||||
elif request.url.path.startswith("/api"):
|
||||
# Allow unauthenticated access for checklist placeholder APIs while keeping
|
||||
# any provided principal for future auth-enabled endpoints.
|
||||
request.state.principal = {}
|
||||
response = await call_next(request)
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user