设备接口
设备管理相关的 API 接口。
注册设备
绑定新设备到当前用户。
请求
http
POST /api/devices
Authorization: Bearer <token>
Content-Type: application/json请求体
json
{
"sn": "MG1-2024-001234",
"mac": "AA:BB:CC:DD:EE:FF",
"productModel": "Mooting G1"
}请求字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| sn | string | 是 | 设备序列号 |
| mac | string | 是 | MAC 地址 |
| productModel | string | 是 | 产品型号 |
响应
成功 (200):
json
{
"sn": "MG1-2024-001234",
"userId": 123,
"mac": "AA:BB:CC:DD:EE:FF",
"productModel": "Mooting G1",
"createdAt": "2026-01-29T10:30:00Z"
}获取设备列表
获取当前用户的所有设备。
请求
http
GET /api/devices
Authorization: Bearer <token>响应
成功 (200):
json
[
{
"sn": "MG1-2024-001234",
"userId": 123,
"mac": "AA:BB:CC:DD:EE:FF",
"productModel": "Mooting G1",
"createdAt": "2026-01-29T10:30:00Z"
},
{
"sn": "MG1-2024-005678",
"userId": 123,
"mac": "11:22:33:44:55:66",
"productModel": "Mooting G1",
"createdAt": "2026-01-28T09:15:00Z"
}
]响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
| sn | string | 设备序列号 |
| userId | number | 所属用户 ID |
| mac | string | MAC 地址 |
| productModel | string | 产品型号 |
| createdAt | string | 绑定时间 (ISO 8601) |