docs + locations
This commit is contained in:
parent
e1618b40ef
commit
48f00d8f6f
17 changed files with 390 additions and 33 deletions
26
src/routes/item/location.rs
Normal file
26
src/routes/item/location.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use mongod::ToAPI;
|
||||
use rocket::{get, State};
|
||||
|
||||
use crate::{
|
||||
json_store::JSONStore,
|
||||
location::Location,
|
||||
routes::{api_error, FallibleApiResponse},
|
||||
};
|
||||
|
||||
#[get("/location/<id>")]
|
||||
pub async fn location_info(
|
||||
id: &str,
|
||||
locations: &State<JSONStore<Location>>,
|
||||
) -> FallibleApiResponse {
|
||||
let loc = locations
|
||||
.get(id)
|
||||
.ok_or_else(|| api_error("No location with that ID"))?;
|
||||
Ok(loc.api().await)
|
||||
}
|
||||
|
||||
#[get("/locations")]
|
||||
pub async fn locations_info(locations: &State<JSONStore<Location>>) -> FallibleApiResponse {
|
||||
// todo : recursive location map
|
||||
|
||||
unimplemented!()
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
mod demand;
|
||||
mod error;
|
||||
mod location;
|
||||
mod supply;
|
||||
|
||||
pub use demand::*;
|
||||
pub use error::*;
|
||||
pub use location::*;
|
||||
use mongod::Model;
|
||||
use mongod::ToAPI;
|
||||
pub use supply::*;
|
||||
|
|
|
@ -16,6 +16,7 @@ pub struct SupplyForm {
|
|||
variant: String,
|
||||
price: String,
|
||||
origin: Option<String>,
|
||||
location: Option<String>,
|
||||
}
|
||||
|
||||
/// Route for supply action. Creates a new Transaction for the specified Item Variant.
|
||||
|
@ -35,6 +36,7 @@ pub async fn supply_route(form: Json<SupplyForm>, itemdb: &State<ItemDB>) -> Fal
|
|||
.try_into()
|
||||
.map_err(|()| api_error("Price malformed"))?,
|
||||
form.origin.as_deref(),
|
||||
form.location.as_deref(),
|
||||
)
|
||||
.await;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue