use axum::{ extract::State, http::StatusCode, Json, }; use crate::auth::structs::AppState; use serde::Serialize; use serde_json::json; #[derive(Serialize)] pub struct ListingId { pub id: i32, pub company_name: String, } pub async fn get_all_active_listing_ids( State(app_state): State, ) -> Result>, (StatusCode, Json)> { match sqlx::query_as!( ListingId, "SELECT id, company_name FROM listings WHERE is_active = true ORDER BY id DESC" ) .fetch_all(&*app_state.db) .await { Ok(ids) => Ok(Json(ids)), Err(e) => Err(( StatusCode::INTERNAL_SERVER_ERROR, Json(json!({"error": format!("Failed to fetch listing ids: {}", e)})) )), } }