2023-08-01 11:48:56 +02:00
|
|
|
use actix_web::web::{scope, Data, ServiceConfig};
|
2023-07-27 17:36:30 +02:00
|
|
|
use actix_web::{get, HttpResponse};
|
2023-07-26 11:16:29 +02:00
|
|
|
|
2023-07-27 17:36:30 +02:00
|
|
|
pub fn mount(config: &mut ServiceConfig) {
|
2023-08-01 11:48:56 +02:00
|
|
|
config.service(scope("/parking_spaces").service(all_parking_spaces));
|
2023-07-27 17:36:30 +02:00
|
|
|
}
|
|
|
|
|
2023-08-01 11:48:56 +02:00
|
|
|
#[get("/all")]
|
2023-07-27 17:36:30 +02:00
|
|
|
async fn all_parking_spaces(db: Data<sea_orm::DatabaseConnection>) -> HttpResponse {
|
2023-07-27 22:54:55 +02:00
|
|
|
use oswilno_contract::parking_spaces;
|
|
|
|
use sea_orm::prelude::*;
|
2023-07-27 17:36:30 +02:00
|
|
|
|
|
|
|
let db = db.into_inner();
|
|
|
|
|
2023-07-27 22:54:55 +02:00
|
|
|
let spaces = parking_spaces::Entity::find().all(&*db).await.unwrap();
|
2023-07-27 17:36:30 +02:00
|
|
|
HttpResponse::Ok().json(spaces)
|
|
|
|
}
|