feat(backend) update (unfinished)

This commit is contained in:
lumither committed 2025-02-22 00:00:13 -08:00
1 parent 84ec754c65
commit 8358a8ae33
20 files changed
+131 -317

No files matched your search

@@ -0,0 +1,30 @@
use axum::response::IntoResponse;
use axum::{
extract::{Path, State},
Json,
};
use serde_json::json;
use sqlx::PgPool;
const GET_POST_BY_I64_ID: &str = include_str!("get_post_by_i64_id.sql");
const GET_POST_BY_STR_ID: &str = include_str!("get_post_by_str_id.sql");
pub async fn handler(
State(db_connection): State<PgPool>,
Path(identifier): Path<String>,
) -> impl IntoResponse {
let post = if let Ok(id) = identifier.parse::<i64>() {
select_post_with_i64_id(&db_connection, id).await
} else {
select_post_with_str_id(&db_connection, &identifier).await
};
Json::from(json!({"res": "ok"})).into_response()
}
async fn select_post_with_i64_id(db: &PgPool, id: i64) {
todo!()
}
async fn select_post_with_str_id(db: &PgPool, id: &str) {
todo!()
}