use bloom_web::prelude::*;
#[derive(Entity, Debug, Clone, Serialize, Deserialize, FromRow)]
#[table("bloom_users")]
#[allow(dead_code)]
pub struct BloomUser {
#[id]
pub id: i32,
pub name: String,
pub email: String,
}
#[repository(BloomUser)]
pub struct UserRepository;
#[get_mapping("/users/{id}")]
pub async fn get_bloom_user_by_id(path: web::Path<i64>, pool: web::Data<MySqlPool>) -> impl actix_web::Responder {
match UserRepository::find_by_id::<BloomUser>(pool.get_ref(), path.into_inner()).await {
Ok(Some(user)) => HttpResponse::Ok().json(user),
Ok(None) => HttpResponse::NotFound().finish(),
Err(_) => HttpResponse::InternalServerError().finish(),
}
}
fn main() {
println!("Bloom Web Framework test with user's code compiled successfully!");
println!("All dependencies are properly accessible including web::Path and actix_web::Responder!");
}