Skip to content

Latest commit

 

History

History
295 lines (243 loc) · 4.33 KB

File metadata and controls

295 lines (243 loc) · 4.33 KB

OVAM API 文档

认证

检查系统状态

GET /api/admin/auth/status

响应

{
  "configured": true
}

登录(密码 + TOTP)

POST /api/admin/auth/login
Content-Type: application/json

{
  "password": "your-password",
  "code": "123456"
}

响应

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "expires_in": 1800
}

修改密码

POST /api/admin/auth/change-password
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "current_password": "old-password",
  "code": "123456",
  "new_password": "new-password"
}

公开接口(客户端)

购买跳转

GET /buy?p=<product_slug>&s=<sku_alias>&d=<device_id>

重定向到爱发电支付页面。

设备激活

POST /api/v1/:slug/activate
Content-Type: application/json

{
  "device_id": "device-123",
  "deviceInfo": {
    "product": "MiBand8",
    "osVersionName": "1.0.0"
  }
}

响应

{
  "status": "success",
  "license": {
    "payload": { ... },
    "signature": "base64..."
  }
}

云控配置

POST /api/v1/:slug/config
Content-Type: application/json

{
  "device_id": "device-123",
  "product": "MiBand8",
  "app_version_code": 120
}

响应

{
  "announcements": [],
  "maintenance": {
    "enabled": false,
    "message": "",
    "end_at": 0
  },
  "feature_toggles": {
    "feature_a": true
  },
  "update": {
    "force": false,
    "latest_version_code": 120,
    "update_url": "",
    "changelog": ""
  },
  "extra_rules": []
}

事件上报

POST /api/v1/:slug/event
Content-Type: application/json

{
  "device_id": "device-123",
  "event_name": "app_launch",
  "data": { ... }
}

反馈上报

POST /api/v1/:slug/feedback
Content-Type: application/json

{
  "device_id": "device-123",
  "content": "用户反馈内容"
}

爱发电 Webhook

POST /api/v1/webhook/afdian
Content-Type: application/json

{
  "sign": "signature",
  "data": {
    "type": "order",
    "order": { ... }
  }
}

管理后台接口(需 JWT)

统计数据

GET /api/admin/stats
Authorization: Bearer <jwt>

配置管理

获取原始配置

GET /api/admin/config/raw
Authorization: Bearer <jwt>

保存配置

POST /api/admin/config/save
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "server": { ... },
  "database": { ... },
  "products": [ ... ]
}

数据查询

GET /api/admin/data/:table?page=1&size=20&q=keyword&product_slug=&sort=created_at+desc
Authorization: Bearer <jwt>

支持表devices, orders, events, feedbacks, audit_logs

查询参数

  • page: 页码(默认 1)
  • size: 每页条数(默认 20,最大 1000)
  • q: 关键词搜索
  • product_slug: 按产品过滤
  • sort: 排序字段(created_at desc
  • activated: true/false(仅 devices)
  • processed: true/false(仅 orders)

设备管理

保存/更新设备

POST /api/admin/devices/save
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "device_id": "device-123",
  "product_slug": "product-slug",
  "expire_at": 1700000000,
  "is_active": true
}

删除设备

DELETE /api/admin/devices/:slug/:device_id
Authorization: Bearer <jwt>

订单管理

修复订单

POST /api/admin/orders/repair
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "out_trade_no": "20210101...",
  "new_device_id": "device-123"
}

删除订单

DELETE /api/admin/orders/:out_trade_no
Authorization: Bearer <jwt>

爱发电同步

GET /api/admin/afdian/sync?plan_id=<plan_id>
Authorization: Bearer <jwt>

RSA 密钥工具

生成新密钥对

POST /api/admin/keys/gen
Authorization: Bearer <jwt>

响应

{
  "private_key": "-----BEGIN PRIVATE KEY-----\n...",
  "public_key": "-----BEGIN PUBLIC KEY-----\n..."
}

从私钥提取公钥

POST /api/admin/keys/extract
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "private_key": "-----BEGIN PRIVATE KEY-----\n..."
}

错误响应

{
  "message": "错误描述"
}

HTTP 状态码

  • 400: 请求参数错误
  • 401: 未认证/认证失败
  • 404: 资源不存在
  • 429: 请求过于频繁(登录速率限制)
  • 500: 服务器内部错误
  • 503: 系统未配置