feat(all): 重炼 crates/common 核心组件、上线 Web 运维看板与 Docker 容器化部署

This commit is contained in:
fmq
2026-07-28 10:31:57 +08:00
commit 4b4238d702
71 changed files with 163402 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
use super::AppState;
use axum::{extract::State, response::IntoResponse, Json};
use common::models::{NodeHeartbeatRequest, NodeRegisterRequest};
use serde_json::json;
pub async fn register_node(
State(state): State<AppState>,
Json(req): Json<NodeRegisterRequest>,
) -> impl IntoResponse {
match state.db.register_node(&req).await {
Ok(_) => Json(json!({"status": "ok", "message": "节点注册成功"})),
Err(e) => Json(json!({"status": "error", "message": e.to_string()})),
}
}
pub async fn heartbeat_node(
State(state): State<AppState>,
Json(req): Json<NodeHeartbeatRequest>,
) -> impl IntoResponse {
match state.db.heartbeat_node(&req).await {
Ok(_) => Json(json!({"status": "ok"})),
Err(e) => Json(json!({"status": "error", "message": e.to_string()})),
}
}