lootaherra identifier
This commit is contained in:
36
src/loota.rs
36
src/loota.rs
@@ -193,8 +193,14 @@ async fn get_admin(path: web::Path<String>) -> impl Responder {
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/lootaherra/orders")]
|
||||
async fn get_admin_orders() -> impl Responder {
|
||||
#[get("/lootaherra/{identifier}/orders")]
|
||||
async fn get_admin_orders(path: web::Path<String>) -> impl Responder {
|
||||
let identifier_param = path.into_inner();
|
||||
|
||||
let exists = web::block(move || find_admin(identifier_param)).await.unwrap();
|
||||
|
||||
match exists {
|
||||
true => {
|
||||
let orders = web::block(move || {
|
||||
let conn = &mut establish_connection();
|
||||
find_admin_orders(conn)
|
||||
@@ -211,15 +217,25 @@ async fn get_admin_orders() -> impl Responder {
|
||||
.await
|
||||
.unwrap(),
|
||||
}
|
||||
},
|
||||
_ => HttpResponse::Forbidden()
|
||||
.content_type(APPLICATION_JSON)
|
||||
.await
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/lootaherra/box-list/{delivery_date}")]
|
||||
async fn get_admin_boxes(path: web::Path<String>) -> impl Responder {
|
||||
let _delivery_date = path.into_inner();
|
||||
#[get("/lootaherra/{identifier}/box-list/{delivery_date}")]
|
||||
async fn get_admin_boxes(path: web::Path<(String, String)>) -> impl Responder {
|
||||
let (identifier_param, delivery_date_param) = path.into_inner();
|
||||
|
||||
let exists = web::block(move || find_admin(identifier_param)).await.unwrap();
|
||||
|
||||
match exists {
|
||||
true => {
|
||||
let boxes = web::block(move || {
|
||||
let conn = &mut establish_connection();
|
||||
find_admin_boxes(_delivery_date, conn)
|
||||
find_admin_boxes(delivery_date_param, conn)
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -232,6 +248,14 @@ async fn get_admin_boxes(path: web::Path<String>) -> impl Responder {
|
||||
.await
|
||||
.unwrap(),
|
||||
}
|
||||
|
||||
},
|
||||
_ => HttpResponse::Forbidden()
|
||||
.content_type(APPLICATION_JSON)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[get("/loota/{id}")]
|
||||
|
||||
Reference in New Issue
Block a user