|
|
@ -558,6 +558,16 @@ async fn get_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntit |
|
|
|
Ok(Meseta(meseta.0 as u32))
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn create_trade(conn: &mut sqlx::PgConnection, char_id1: &CharacterEntityId, char_id2: &CharacterEntityId) -> Result<TradeEntity, GatewayError>
|
|
|
|
{
|
|
|
|
let trade = sqlx::query_as::<_, PgTradeEntity>(r#"insert into trades (character1, character2) values ($1, $2) returning *;"#)
|
|
|
|
.bind(char_id1.0)
|
|
|
|
.bind(char_id2.0)
|
|
|
|
.fetch_one(conn)
|
|
|
|
.await?;
|
|
|
|
Ok(trade.into())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl EntityGateway for PostgresGateway {
|
|
|
|
async fn transaction<'a>(&'a mut self) -> Result<Box<dyn EntityGatewayTransaction + 'a>, GatewayError>
|
|
|
@ -693,6 +703,10 @@ impl EntityGateway for PostgresGateway { |
|
|
|
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName) -> Result<Meseta, GatewayError> {
|
|
|
|
get_bank_meseta(&mut *self.pool.acquire().await?, char_id, bank).await
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn create_trade(&mut self, char_id1: &CharacterEntityId, char_id2: &CharacterEntityId) -> Result<TradeEntity, GatewayError> {
|
|
|
|
create_trade(&mut *self.pool.acquire().await?, char_id1, char_id2).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -809,5 +823,9 @@ impl<'c> EntityGateway for PostgresTransaction<'c> { |
|
|
|
async fn get_bank_meseta(&mut self, char_id: &CharacterEntityId, bank: &BankName) -> Result<Meseta, GatewayError> {
|
|
|
|
get_bank_meseta(&mut *self.pgtransaction, char_id, bank).await
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn create_trade(&mut self, char_id1: &CharacterEntityId, char_id2: &CharacterEntityId) -> Result<TradeEntity, GatewayError> {
|
|
|
|
create_trade(&mut *self.pgtransaction, char_id1, char_id2).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|