feat(backend/api/get/post_list) add first_update field

This commit is contained in:
lumither committed 2024-05-04 14:02:54 +08:00
1 parent 7e3687c4c9
commit 4e71a1ccf0
1 file changed
+4 -1
+4 -1
View File
@@ -8,7 +8,8 @@ use uuid::Uuid;
pub async fn get_post_list(
State(db_connection): State<PgPool>,
) -> Result<Json<Value>, Json<Value>> {
let post_list = sqlx::query("select post_id, title, summary, last_update from post")
let post_list =
sqlx::query("select post_id, title, summary, last_update, first_update from post")
.fetch_all(&db_connection)
.await
.unwrap();
@@ -22,11 +23,13 @@ pub async fn get_post_list(
let title: String = post.get("title");
let summary: String = post.get("summary");
let last_update: NaiveDateTime = post.get("last_update");
let first_update: NaiveDateTime = post.get("first_update");
tmp.insert("post_id".to_string(), json!(post_id.to_string()));
tmp.insert("title".to_string(), json!(title));
tmp.insert("summary".to_string(), json!(summary));
tmp.insert("last_update".to_string(), json!(last_update));
tmp.insert("first_update".to_string(), json!(first_update));
Value::from(tmp)
})