34 lines
1.0 KiB
Rust
34 lines
1.0 KiB
Rust
use actix_web::{error, web, Error, HttpResponse};
|
|
|
|
use crate::db::{self, Pool};
|
|
|
|
pub async fn get_teachers_json(pool: web::Data<Pool>) -> Result<HttpResponse, Error> {
|
|
let tasks = db::read::get_teachers(&pool)
|
|
.await
|
|
.map_err(error::ErrorInternalServerError)?;
|
|
|
|
Ok(HttpResponse::Ok().json(tasks))
|
|
}
|
|
pub async fn get_subjects_json(pool: web::Data<Pool>) -> Result<HttpResponse, Error> {
|
|
let tasks = db::read::get_subjects(&pool)
|
|
.await
|
|
.map_err(error::ErrorInternalServerError)?;
|
|
|
|
Ok(HttpResponse::Ok().json(tasks))
|
|
}
|
|
|
|
pub async fn get_slots_json(pool: web::Data<Pool>) -> Result<HttpResponse, Error> {
|
|
let tasks = db::read::get_slots(&pool)
|
|
.await
|
|
.map_err(error::ErrorInternalServerError)?;
|
|
|
|
Ok(HttpResponse::Ok().json(tasks))
|
|
}
|
|
pub async fn get_unavailable_json(pool: web::Data<Pool>) -> Result<HttpResponse, Error> {
|
|
let tasks = db::read::get_unavailable(&pool)
|
|
.await
|
|
.map_err(error::ErrorInternalServerError)?;
|
|
|
|
Ok(HttpResponse::Ok().json(tasks))
|
|
}
|