refactor(api): split Axum handlers into handler/service/repo modules

Keep the REST contract; move domain logic out of route files so checkout, fulfillment, and identity can be reused across customer, shop, and admin surfaces.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Chengdong Zhang
2026-09-18 14:59:36 +08:00
co-authored by Cursor
parent e457339847
commit 5e866d08f4
68 changed files with 3796 additions and 2304 deletions
+27
View File
@@ -0,0 +1,27 @@
use axum::{extract::State, routing::get, Json, Router};
use redis::AsyncCommands;
use serde_json::{json, Value};
use crate::error::ApiResult;
use crate::state::AppState;
pub fn router() -> Router<AppState> {
Router::new().route("/ready", get(ready))
}
pub async fn health() -> Json<Value> {
Json(json!({ "status": "ok" }))
}
pub async fn ready(State(state): State<AppState>) -> ApiResult<Json<Value>> {
let db_ok = sqlx::query_scalar::<_, i32>("SELECT 1")
.fetch_one(&state.db)
.await
.is_ok();
let mut redis = state.redis.clone();
let redis_ok = redis
.set::<_, _, ()>("vmall:ready:ping", "1")
.await
.is_ok();
Ok(Json(json!({ "db": db_ok, "redis": redis_ok })))
}