postgres
This commit is contained in:
parent
584ffb6b11
commit
1faa3b9668
19 changed files with 1058 additions and 1244 deletions
|
@ -1,4 +1,3 @@
|
|||
use mongod::ToAPI;
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::{get, post, State};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -6,7 +5,7 @@ use serde_json::json;
|
|||
|
||||
use crate::check_auth;
|
||||
use crate::config::{Config, Webhook};
|
||||
use crate::routes::Token;
|
||||
use crate::routes::{vec_to_api, ToAPI, Token};
|
||||
use crate::{
|
||||
db::ItemDB,
|
||||
routes::{api_error, FallibleApiResponse},
|
||||
|
@ -18,7 +17,7 @@ use super::{item_does_not_exist_error, variant_does_not_exist_error};
|
|||
pub struct SupplyForm {
|
||||
pub item: String,
|
||||
pub variant: String,
|
||||
pub price: String,
|
||||
pub price: f64,
|
||||
pub origin: Option<String>,
|
||||
pub location: Option<String>,
|
||||
pub note: Option<String>,
|
||||
|
@ -42,10 +41,7 @@ pub async fn supply_route(
|
|||
|
||||
let transaction = variant
|
||||
.supply(
|
||||
form.price
|
||||
.clone()
|
||||
.try_into()
|
||||
.map_err(|()| api_error("Price malformed"))?,
|
||||
form.price,
|
||||
form.origin.as_deref(),
|
||||
form.location.as_deref(),
|
||||
form.note.as_deref(),
|
||||
|
@ -58,7 +54,7 @@ pub async fn supply_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(json!({"uuid": transaction._id}))
|
||||
Ok(json!({"uuid": transaction.id}))
|
||||
}
|
||||
|
||||
/// Returns a list of Transaction UUIDs for the Item Variant
|
||||
|
@ -104,7 +100,7 @@ pub async fn inventory_route(
|
|||
item.inventory().await
|
||||
};
|
||||
|
||||
Ok(json!(mongod::vec_to_api(&transactions).await))
|
||||
Ok(json!(vec_to_api(&transactions).await))
|
||||
}
|
||||
|
||||
/// Returns current active Transactions for Item Variant
|
||||
|
@ -126,7 +122,7 @@ pub async fn inventory_route_variant(
|
|||
|
||||
let transactions = variant.inventory().await;
|
||||
|
||||
Ok(json!(mongod::vec_to_api(&transactions).await))
|
||||
Ok(json!(vec_to_api(&transactions).await))
|
||||
}
|
||||
|
||||
/// Returns statistics for the Item Variant
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue