headless_lms_server/controllers/course_material/
organizations.rs1use headless_lms_models::organizations::Organization;
4
5use crate::prelude::*;
6
7#[instrument(skip(pool, file_store, app_conf))]
11async fn get_organization(
12 organization_id: web::Path<Uuid>,
13 pool: web::Data<PgPool>,
14 file_store: web::Data<dyn FileStore>,
15 app_conf: web::Data<ApplicationConfiguration>,
16) -> ControllerResult<web::Json<Organization>> {
17 let mut conn = pool.acquire().await?;
18 let token = skip_authorize();
19 let db_organization =
20 models::organizations::get_organization(&mut conn, *organization_id).await?;
21 let organization =
22 Organization::from_database_organization(db_organization, file_store.as_ref(), &app_conf);
23 token.authorized_ok(web::Json(organization))
24}
25
26pub fn _add_routes(cfg: &mut ServiceConfig) {
34 cfg.route("/{organization_id}", web::get().to(get_organization));
35}