♻️ refactor + location conditions
This commit is contained in:
parent
ce9cdc4256
commit
3076ebe6a0
19 changed files with 1228 additions and 520 deletions
|
@ -1,15 +1,15 @@
|
|||
use rocket::serde::json::Json;
|
||||
use rocket::{get, post, State};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::check_auth;
|
||||
use crate::config::{Config, Webhook};
|
||||
use crate::routes::{vec_to_api, ToAPI, Token};
|
||||
use crate::routes::Token;
|
||||
use crate::{
|
||||
db::ItemDB,
|
||||
routes::{api_error, FallibleApiResponse},
|
||||
routes::{FallibleApiResponse, api_error},
|
||||
};
|
||||
use based::request::api::{ToAPI, vec_to_api};
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::{State, get, post};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
use super::{item_does_not_exist_error, variant_does_not_exist_error};
|
||||
|
||||
|
@ -23,8 +23,8 @@ pub struct SupplyForm {
|
|||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
/// Route for supply action. Creates a new Transaction for the specified Item Variant.
|
||||
#[post("/supply", data = "<form>")]
|
||||
/// Route for supply action. Creates a new Transaction for the specified Item Variant.
|
||||
pub async fn supply_route(
|
||||
form: Json<SupplyForm>,
|
||||
itemdb: &State<ItemDB>,
|
||||
|
@ -57,8 +57,8 @@ pub async fn supply_route(
|
|||
Ok(json!({"uuid": transaction.id}))
|
||||
}
|
||||
|
||||
/// Returns a list of Transaction UUIDs for the Item Variant
|
||||
#[get("/item/<item_id>/<variant_id>/supply")]
|
||||
/// Returns a list of Transaction UUIDs for the Item Variant
|
||||
pub async fn supply_log_route(
|
||||
item_id: &str,
|
||||
variant_id: &str,
|
||||
|
@ -79,8 +79,8 @@ pub async fn supply_log_route(
|
|||
Ok(json!(transactions))
|
||||
}
|
||||
|
||||
/// Returns current active Transactions for Item
|
||||
#[get("/item/<item_id>/inventory?<origin>")]
|
||||
/// Returns current active Transactions for Item
|
||||
pub async fn inventory_route(
|
||||
item_id: &str,
|
||||
itemdb: &State<ItemDB>,
|
||||
|
@ -103,8 +103,8 @@ pub async fn inventory_route(
|
|||
Ok(json!(vec_to_api(&transactions).await))
|
||||
}
|
||||
|
||||
/// Returns current active Transactions for Item Variant
|
||||
#[get("/item/<item_id>/<variant_id>/inventory")]
|
||||
/// Returns current active Transactions for Item Variant
|
||||
pub async fn inventory_route_variant(
|
||||
item_id: &str,
|
||||
variant_id: &str,
|
||||
|
@ -125,8 +125,8 @@ pub async fn inventory_route_variant(
|
|||
Ok(json!(vec_to_api(&transactions).await))
|
||||
}
|
||||
|
||||
/// Returns statistics for the Item Variant
|
||||
#[get("/item/<item_id>/<variant_id>/stat?<full>")]
|
||||
/// Returns statistics for the Item Variant
|
||||
pub async fn variant_stat_route(
|
||||
item_id: &str,
|
||||
variant_id: &str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue