works on selling group items
This commit is contained in:
@@ -10,7 +10,6 @@ use crate::api;
|
||||
type AppPool = web::Data<db::Pool>;
|
||||
type PlayerId = web::Path<i32>;
|
||||
type ItemId = web::Json<i32>;
|
||||
type ItemListWithMods = web::Json<Vec<(i32, Option<f64>)>>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct NewGroupLoot {
|
||||
@@ -99,18 +98,21 @@ fn configure_app(config: &mut web::ServiceConfig) {
|
||||
db_call(pool, Q::FetchLoot(*player))
|
||||
}))
|
||||
.route(web::put().to_async(
|
||||
move |pool, (player, data): (PlayerId, ItemListWithMods)| {
|
||||
move |pool, (player, data): (PlayerId, web::Json<api::ItemListWithMods>)| {
|
||||
db_call(pool, Q::BuyItems(*player, data.into_inner()))
|
||||
},
|
||||
))
|
||||
.route(web::post().to(
|
||||
move |pool, (player, data): (PlayerId, web::Json<NewGroupLoot>)| {
|
||||
forbidden_to_players(*player, (pool, Q::AddLoot(data.items.clone())))
|
||||
forbidden_to_players(*player, (pool, Q::AddLoot(data.into_inner().items)))
|
||||
},
|
||||
))
|
||||
.route(web::delete().to_async(
|
||||
move |pool, (player, data): (PlayerId, ItemListWithMods)| {
|
||||
db_call(pool, Q::SellItems(*player, data.into_inner()))
|
||||
move |pool, (player, data): (PlayerId, web::Json<api::SellParams>)| {
|
||||
match *player {
|
||||
0 => db_call(pool, Q::SellItems(*player, data.into_inner().items)),
|
||||
_ => db_call(pool, Q::SellGroupItems(*player, data.into_inner())),
|
||||
}
|
||||
},
|
||||
)),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user