member is modified

This commit is contained in:
병준 박 2022-08-22 12:23:00 +00:00
parent 7e0746ad2a
commit f9e6c208ce
6 changed files with 832 additions and 754 deletions

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,14 @@ pub struct NewMemberGameSetting {
pub can_bet_bogglepowerball: bool, pub can_bet_bogglepowerball: bool,
} }
///
#[derive(Insertable, Debug, Clone)]
#[table_name = "member_game_settings"]
pub struct NewMemberGameSettingForDefault {
///
pub member_id: uuid::Uuid,
}
/// ///
#[derive(AsChangeset, Debug, Clone)] #[derive(AsChangeset, Debug, Clone)]
#[table_name = "member_game_settings"] #[table_name = "member_game_settings"]

View File

@ -40,6 +40,19 @@ impl Repository {
Ok(inserted) Ok(inserted)
} }
///
pub fn insert_with_default(
&self,
conn: &diesel::PgConnection,
new_resource: &models::NewMemberGameSettingForDefault,
) -> Result<models::MemberGameSetting, Error> {
let inserted = diesel::insert_into(member_game_settings::table)
.values(new_resource)
.get_result::<models::MemberGameSetting>(conn)?;
Ok(inserted)
}
/// ///
pub fn select( pub fn select(
&self, &self,

View File

@ -103,6 +103,14 @@ pub struct NewMemberSettlementSetting {
pub rate_bogglepowerball_combo: f64, pub rate_bogglepowerball_combo: f64,
} }
///
#[derive(Insertable, Debug, Clone)]
#[table_name = "member_settlement_settings"]
pub struct NewMemberSettlementSettingForDefault {
///
pub member_id: uuid::Uuid,
}
/// ///
#[derive(AsChangeset, Debug, Clone)] #[derive(AsChangeset, Debug, Clone)]
#[table_name = "member_settlement_settings"] #[table_name = "member_settlement_settings"]

View File

@ -40,6 +40,19 @@ impl Repository {
Ok(inserted) Ok(inserted)
} }
///
pub fn insert_with_default(
&self,
conn: &diesel::PgConnection,
new_resource: &models::NewMemberSettlementSettingForDefault,
) -> Result<models::MemberSettlementSetting, Error> {
let inserted = diesel::insert_into(member_settlement_settings::table)
.values(new_resource)
.get_result::<models::MemberSettlementSetting>(conn)?;
Ok(inserted)
}
/// ///
pub fn select( pub fn select(
&self, &self,

View File

@ -391,70 +391,106 @@ impl Service<'_> {
})?; })?;
} }
if let Some(a) = request.game_setting { match request.game_setting {
let new_member_game_setting = Some(a) => {
repositories::member_game_setting::models::NewMemberGameSetting { let new_member_game_setting =
member_id: m.id, repositories::member_game_setting::models::NewMemberGameSetting {
can_bet_casino: a.can_bet_casino, member_id: m.id,
can_bet_slot: a.can_bet_slot, can_bet_casino: a.can_bet_casino,
can_bet_powerball: a.can_bet_powerball, can_bet_slot: a.can_bet_slot,
can_bet_powerladder: a.can_bet_powerladder, can_bet_powerball: a.can_bet_powerball,
can_bet_eos: a.can_bet_eos, can_bet_powerladder: a.can_bet_powerladder,
can_bet_bogglepowerball: a.can_bet_bogglepowerball, can_bet_eos: a.can_bet_eos,
}; can_bet_bogglepowerball: a.can_bet_bogglepowerball,
self };
.member_game_setting_repository self
.insert(&conn, &new_member_game_setting) .member_game_setting_repository
.map_err(|e| { .insert(&conn, &new_member_game_setting)
bcr::error::rpc::Error::Server(bcr::error::rpc::Server { .map_err(|e| {
code: bpr::protobuf::rpc::Error::SERVER_00, bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
message: format!("server {}", e), code: bpr::protobuf::rpc::Error::SERVER_00,
data: None, message: format!("server {}", e),
}) data: None,
})?; })
})?;
}
None => {
let new_member_game_setting =
repositories::member_game_setting::models::NewMemberGameSettingForDefault {
member_id: m.id,
};
self
.member_game_setting_repository
.insert_with_default(&conn, &new_member_game_setting)
.map_err(|e| {
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
code: bpr::protobuf::rpc::Error::SERVER_00,
message: format!("server {}", e),
data: None,
})
})?;
}
} }
if let Some(a) = request.settlement_setting { match request.settlement_setting {
let new_member_settlement_setting = Some(a) => {
repositories::member_settlement_setting::models::NewMemberSettlementSetting { let new_member_settlement_setting =
member_id: m.id, repositories::member_settlement_setting::models::NewMemberSettlementSetting {
can_exchange: a.can_exchange, member_id: m.id,
can_first_charge_comp: a.can_first_charge_comp, can_exchange: a.can_exchange,
can_per_charge_comp: a.can_per_charge_comp, can_first_charge_comp: a.can_first_charge_comp,
manual_payment_type_for_partner: can_per_charge_comp: a.can_per_charge_comp,
repositories::member_settlement_setting::schema::ManualPaymentType::from( manual_payment_type_for_partner:
a.manual_payment_type_for_partner, repositories::member_settlement_setting::schema::ManualPaymentType::from(
), a.manual_payment_type_for_partner,
settlement_type: ),
repositories::member_settlement_setting::schema::SettlementType::from( settlement_type:
a.settlement_type, repositories::member_settlement_setting::schema::SettlementType::from(
), a.settlement_type,
rate_casino: a.rate_casino, ),
rate_casino_loosing: a.rate_casino_loosing, rate_casino: a.rate_casino,
rate_casino_bacara: a.rate_casino_bacara, rate_casino_loosing: a.rate_casino_loosing,
rate_casino_roulette: a.rate_casino_roulette, rate_casino_bacara: a.rate_casino_bacara,
rate_casino_dragon_tiger: a.rate_casino_dragon_tiger, rate_casino_roulette: a.rate_casino_roulette,
rate_slot: a.rate_slot, rate_casino_dragon_tiger: a.rate_casino_dragon_tiger,
rate_slot_loosing: a.rate_slot_loosing, rate_slot: a.rate_slot,
rate_powerball_single: a.rate_powerball_single, rate_slot_loosing: a.rate_slot_loosing,
rate_powerball_combo: a.rate_powerball_combo, rate_powerball_single: a.rate_powerball_single,
rate_powerladder_single: a.rate_powerladder_single, rate_powerball_combo: a.rate_powerball_combo,
rate_powerladder_combo: a.rate_powerladder_combo, rate_powerladder_single: a.rate_powerladder_single,
rate_eos_single: a.rate_eos_single, rate_powerladder_combo: a.rate_powerladder_combo,
rate_eos_combo: a.rate_eos_combo, rate_eos_single: a.rate_eos_single,
rate_bogglepowerball_single: a.rate_bogglepowerball_single, rate_eos_combo: a.rate_eos_combo,
rate_bogglepowerball_combo: a.rate_bogglepowerball_combo, rate_bogglepowerball_single: a.rate_bogglepowerball_single,
}; rate_bogglepowerball_combo: a.rate_bogglepowerball_combo,
self };
.member_settlement_setting_repository self
.insert(&conn, &new_member_settlement_setting) .member_settlement_setting_repository
.map_err(|e| { .insert(&conn, &new_member_settlement_setting)
bcr::error::rpc::Error::Server(bcr::error::rpc::Server { .map_err(|e| {
code: bpr::protobuf::rpc::Error::SERVER_00, bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
message: format!("server {}", e), code: bpr::protobuf::rpc::Error::SERVER_00,
data: None, message: format!("server {}", e),
}) data: None,
})?; })
})?;
}
None => {
let new_member_settlement_setting =
repositories::member_settlement_setting::models::NewMemberSettlementSettingForDefault {
member_id: m.id,
};
self
.member_settlement_setting_repository
.insert_with_default(&conn, &new_member_settlement_setting)
.map_err(|e| {
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
code: bpr::protobuf::rpc::Error::SERVER_00,
message: format!("server {}", e),
data: None,
})
})?;
}
} }
let member = self.member_composition.select(&conn, m.id).map_err(|e| { let member = self.member_composition.select(&conn, m.id).map_err(|e| {