remove change_item
This commit is contained in:
parent
c22b23ef03
commit
fb6eaeffd2
@ -65,11 +65,6 @@ pub trait EntityGateway: Send + Sync + Clone {
|
|||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove
|
|
||||||
async fn change_item(&mut self, _id: &ItemEntityId, _item: &ItemDetail) -> Result<(), GatewayError> {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn change_item_location(&mut self, _item_id: &ItemEntityId, _item_location: ItemLocation) -> Result<(), GatewayError> {
|
async fn change_item_location(&mut self, _item_id: &ItemEntityId, _item_location: ItemLocation) -> Result<(), GatewayError> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
@ -223,15 +223,6 @@ impl EntityGateway for InMemoryGateway {
|
|||||||
Ok(new_item)
|
Ok(new_item)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn change_item(&mut self, id: &ItemEntityId, item: &ItemDetail) -> Result<(), GatewayError> {
|
|
||||||
let mut items = self.items.lock().unwrap();
|
|
||||||
if let Some((_, ref mut old_item)) = items.iter_mut().find(|(existing_id, _)| **existing_id == *id) {
|
|
||||||
old_item.item = item.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn change_item_location(&mut self, item_id: &ItemEntityId, item_location: ItemLocation) -> Result<(), GatewayError> {
|
async fn change_item_location(&mut self, item_id: &ItemEntityId, item_location: ItemLocation) -> Result<(), GatewayError> {
|
||||||
self.items.lock().unwrap().get_mut(&item_id)
|
self.items.lock().unwrap().get_mut(&item_id)
|
||||||
.map(|item_entity| {
|
.map(|item_entity| {
|
||||||
|
@ -331,14 +331,6 @@ impl EntityGateway for PostgresGateway {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn change_item(&mut self, id: &ItemEntityId, item: &ItemDetail) -> Result<(), GatewayError> {
|
|
||||||
sqlx::query("update item set item = $1 where id = $2")
|
|
||||||
.bind(sqlx::types::Json(PgItemDetail::from(item.clone())))
|
|
||||||
.bind(id.0)
|
|
||||||
.execute(&self.pool).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn change_item_location(&mut self, item_id: &ItemEntityId, item_location: ItemLocation) -> Result<(), GatewayError> {
|
async fn change_item_location(&mut self, item_id: &ItemEntityId, item_location: ItemLocation) -> Result<(), GatewayError> {
|
||||||
sqlx::query("insert into item_location (item, location) values ($1, $2)")
|
sqlx::query("insert into item_location (item, location) values ($1, $2)")
|
||||||
.bind(item_id.0)
|
.bind(item_id.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user