Stations API
API quản lý trạm quan trắc.
Danh sách trạm
GET /api/v1/stations
Response:
{
"data": [
{
"id": "uuid",
"name": "Trạm Hoàn Kiếm",
"externalId": "HN-HK-001",
"city": "Hà Nội",
"country": "VN",
"location": {
"type": "Point",
"coordinates": [105.8542, 21.0285]
},
"priority": "HIGH",
"isActive": true,
"inMaintenance": false,
"createdAt": "2025-01-01T00:00:00Z"
}
]
}
Trạm đang hoạt động
GET /api/v1/stations/active
Tìm trạm gần nhất theo GPS
GET /api/v1/stations/nearest
Query Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
| lat | number | Yes | Vĩ độ |
| lon | number | Yes | Kinh độ |
Thống kê trạm
GET /api/v1/stations/stats
Authorization: Bearer <ADMIN_TOKEN>
Response:
{
"total": 4,
"active": 4,
"inactive": 0,
"maintenance": 0,
"byCity": [{ "city": "Hà Nội", "count": 4 }],
"byPriority": [
{ "priority": "HIGH", "count": 2 },
{ "priority": "MEDIUM", "count": 2 }
]
}
Chi tiết trạm
GET /api/v1/stations/:id
Tạo trạm mới (Admin)
POST /api/v1/stations
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
"name": "Trạm Hoàn Kiếm",
"externalId": "HN-HK-001",
"city": "Hà Nội",
"country": "VN",
"latitude": 21.0285,
"longitude": 105.8542,
"priority": "HIGH"
}
Cập nhật trạm (Admin)
PUT /api/v1/stations/:id
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
"name": "Trạm Hoàn Kiếm - Updated",
"priority": "MEDIUM"
}
Xóa trạm (Admin)
DELETE /api/v1/stations/:id
Authorization: Bearer <ADMIN_TOKEN>
Đặt trạm vào chế độ bảo trì (Admin)
POST /api/v1/stations/:id/maintenance
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
"inMaintenance": true
}
Kích hoạt trạm
POST /api/v1/stations/:id/activate
Authorization: Bearer <ADMIN_TOKEN>
Vô hiệu hóa trạm
POST /api/v1/stations/:id/deactivate
Authorization: Bearer <ADMIN_TOKEN>