|
@ -97,7 +97,8 @@ impl PostgresGateway { |
|
|
#[async_trait::async_trait]
|
|
|
#[async_trait::async_trait]
|
|
|
impl EntityGateway for PostgresGateway {
|
|
|
impl EntityGateway for PostgresGateway {
|
|
|
async fn create_user(&mut self, user: NewUserAccountEntity) -> Option<UserAccountEntity> {
|
|
|
async fn create_user(&mut self, user: NewUserAccountEntity) -> Option<UserAccountEntity> {
|
|
|
let new_user = sqlx::query_as::<_, PgUserAccount>("insert into user_accounts (name, password) values ($1, $2) returning *;")
|
|
|
|
|
|
|
|
|
let new_user = sqlx::query_as::<_, PgUserAccount>("insert into user_accounts (email, username, password) values ($1, $2, $3) returning *;")
|
|
|
|
|
|
.bind(user.email)
|
|
|
.bind(user.username)
|
|
|
.bind(user.username)
|
|
|
.bind(user.password)
|
|
|
.bind(user.password)
|
|
|
.fetch_one(&self.pool).await.unwrap();
|
|
|
.fetch_one(&self.pool).await.unwrap();
|
|
@ -112,7 +113,7 @@ impl EntityGateway for PostgresGateway { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
async fn get_user_by_name(&self, username: String) -> Option<UserAccountEntity> {
|
|
|
async fn get_user_by_name(&self, username: String) -> Option<UserAccountEntity> {
|
|
|
let user = sqlx::query_as::<_, PgUserAccount>("select * from user_accounts where name = $1")
|
|
|
|
|
|
|
|
|
let user = sqlx::query_as::<_, PgUserAccount>("select * from user_accounts where username = $1")
|
|
|
.bind(username)
|
|
|
.bind(username)
|
|
|
.fetch_one(&self.pool).await.unwrap();
|
|
|
.fetch_one(&self.pool).await.unwrap();
|
|
|
Some(user.into())
|
|
|
Some(user.into())
|
|
@ -167,9 +168,9 @@ impl EntityGateway for PostgresGateway { |
|
|
async fn create_character(&mut self, char: NewCharacterEntity) -> Option<CharacterEntity> {
|
|
|
async fn create_character(&mut self, char: NewCharacterEntity) -> Option<CharacterEntity> {
|
|
|
let q = r#"insert into player_character
|
|
|
let q = r#"insert into player_character
|
|
|
(user_account, slot, name, exp, class, section_id, costume, skin, face, head, hair, hair_r, hair_g, hair_b, prop_x, prop_y, techs,
|
|
|
(user_account, slot, name, exp, class, section_id, costume, skin, face, head, hair, hair_r, hair_g, hair_b, prop_x, prop_y, techs,
|
|
|
config, infoboard, guildcard, power, mind, def, evade, luck, hp, tp, tech_menu, meseta, bank_meseta)
|
|
|
|
|
|
|
|
|
config, infoboard, guildcard, power, mind, def, evade, luck, hp, tp, tech_menu, meseta, bank_meseta, option_flags)
|
|
|
values
|
|
|
values
|
|
|
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30)
|
|
|
|
|
|
|
|
|
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31)
|
|
|
returning *;"#;
|
|
|
returning *;"#;
|
|
|
let character = sqlx::query_as::<_, PgCharacter>(q)
|
|
|
let character = sqlx::query_as::<_, PgCharacter>(q)
|
|
|
//sqlx::query(q)
|
|
|
//sqlx::query(q)
|
|
@ -203,6 +204,7 @@ impl EntityGateway for PostgresGateway { |
|
|
.bind(char.tech_menu.tech_menu.to_vec())
|
|
|
.bind(char.tech_menu.tech_menu.to_vec())
|
|
|
.bind(char.meseta as i32)
|
|
|
.bind(char.meseta as i32)
|
|
|
.bind(char.bank_meseta as i32)
|
|
|
.bind(char.bank_meseta as i32)
|
|
|
|
|
|
.bind(char.option_flags as i32)
|
|
|
.fetch_one(&self.pool).await.unwrap();
|
|
|
.fetch_one(&self.pool).await.unwrap();
|
|
|
|
|
|
|
|
|
sqlx::query("insert into inventory_slots (pchar) values ($1)")
|
|
|
sqlx::query("insert into inventory_slots (pchar) values ($1)")
|
|
|