headless_lms_server/controllers/course_material/
organizations.rs1use headless_lms_models::organizations::Organization;
4use utoipa::OpenApi;
5
6use crate::prelude::*;
7
8#[derive(OpenApi)]
9#[openapi(paths(get_organization))]
10pub(crate) struct CourseMaterialOrganizationsApiDoc;
11
12#[utoipa::path(
16 get,
17 path = "/{organization_id}",
18 operation_id = "getCourseMaterialOrganization",
19 tag = "course-material-organizations",
20 params(
21 ("organization_id" = Uuid, Path, description = "Organization id")
22 ),
23 responses(
24 (status = 200, description = "Organization", body = Organization)
25 )
26)]
27#[instrument(skip(pool, file_store, app_conf))]
28async fn get_organization(
29 organization_id: web::Path<Uuid>,
30 pool: web::Data<PgPool>,
31 file_store: web::Data<dyn FileStore>,
32 app_conf: web::Data<ApplicationConfiguration>,
33) -> ControllerResult<web::Json<Organization>> {
34 let mut conn = pool.acquire().await?;
35 let token = skip_authorize();
36 let db_organization =
37 models::organizations::get_organization(&mut conn, *organization_id).await?;
38 let organization =
39 Organization::from_database_organization(db_organization, file_store.as_ref(), &app_conf);
40 token.authorized_ok(web::Json(organization))
41}
42
43pub fn _add_routes(cfg: &mut ServiceConfig) {
51 cfg.route("/{organization_id}", web::get().to(get_organization));
52}