From a24d3dddb0a4554e9a6f1d829a3eceae44fbb6f5 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Thu, 1 Sep 2022 09:38:50 +0000 Subject: [PATCH] model is modified --- Cargo.toml | 4 +- src/compositions/member/composition.rs | 310 ++++++++++++------- src/compositions/member/models.rs | 397 ++++++++++++++++++------- src/services/member/models.rs | 55 +++- 4 files changed, 535 insertions(+), 231 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e1f1f51..5a7a683 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio-cron-scheduler = { version = "0" } uuid = { version = "0", features = ["serde", "v4", "v5"] } -beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.89-snapshot" } -beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.75-snapshot" } +beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.92-snapshot" } +beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.78-snapshot" } [build-dependencies] diff --git a/src/compositions/member/composition.rs b/src/compositions/member/composition.rs index 117db14..57ff20f 100644 --- a/src/compositions/member/composition.rs +++ b/src/compositions/member/composition.rs @@ -25,122 +25,216 @@ SELECT m.updated_at as m_updated_at, m.deleted_at as m_deleted_at, - s.id as s_id, - s.url as s_url, - s.name as s_name, - s.path as s_path, - s.show as s_show, - s.can_use as s_can_use, - s.memo as s_memo, - s.expires_at as s_expires_at, - s.created_at as s_created_at, - s.updated_at as s_updated_at, + m_s.id as m_s_id, + m_s.url as m_s_url, + m_s.name as m_s_name, + m_s.path as m_s_path, + m_s.show as m_s_show, + m_s.can_use as m_s_can_use, + m_s.memo as m_s_memo, + m_s.expires_at as m_s_expires_at, + m_s.created_at as m_s_created_at, + m_s.updated_at as m_s_updated_at, - mc.id as mc_id, - mc.parent_id as mc_parent_id, - mc.name as mc_name, - mc.show as mc_show, - mc.created_at as mc_created_at, - mc.updated_at as mc_updated_at, + m_mc.id as m_mc_id, + m_mc.parent_id as m_mc_parent_id, + m_mc.name as m_mc_name, + m_mc.show as m_mc_show, + m_mc.created_at as m_mc_created_at, + m_mc.updated_at as m_mc_updated_at, - ml.id as ml_id, - ml.name as ml_name, - ml.show as ml_show, - ml.sort_order as ml_sort_order, - ml.created_at as ml_created_at, - ml.updated_at as ml_updated_at, + m_ml.id as m_ml_id, + m_ml.name as m_ml_name, + m_ml.show as m_ml_show, + m_ml.sort_order as m_ml_sort_order, + m_ml.created_at as m_ml_created_at, + m_ml.updated_at as m_ml_updated_at, - _m.id as _m_id, - _m.site_id as _m_site_id, - _m.member_class_id as _m_member_class_id, - _m.member_level_id as _m_member_level_id, - _m.username as _m_username, - _m.password as _m_password, - _m.nickname as _m_nickname, - _m.mobile_phone_number as _m_mobile_phone_number, - _m.state as _m_state, - _m.state_changed_at as _m_state_changed_at, - _m.parent_member_id as _m_parent_member_id, - _m.child_member_count as _m_child_member_count, - _m.last_signined_ip as _m_last_signined_ip, - _m.last_signined_at as _m_last_signined_at, - _m.created_at as _m_created_at, - _m.updated_at as _m_updated_at, - _m.deleted_at as _m_deleted_at, + m_mgs.id as m_mgs_id, + m_mgs.member_id as m_mgs_member_id, + m_mgs.can_bet_casino as m_mgs_can_bet_casino, + m_mgs.can_bet_slot as m_mgs_can_bet_slot, + m_mgs.can_bet_powerball as m_mgs_can_bet_powerball, + m_mgs.can_bet_powerladder as m_mgs_can_bet_powerladder, + m_mgs.can_bet_eos as m_mgs_can_bet_eos, + m_mgs.can_bet_bogglepowerball as m_mgs_can_bet_bogglepowerball, + m_mgs.created_at as m_mgs_created_at, + m_mgs.updated_at as m_mgs_updated_at, - mgs.id as mgs_id, - mgs.member_id as mgs_member_id, - mgs.can_bet_casino as mgs_can_bet_casino, - mgs.can_bet_slot as mgs_can_bet_slot, - mgs.can_bet_powerball as mgs_can_bet_powerball, - mgs.can_bet_powerladder as mgs_can_bet_powerladder, - mgs.can_bet_eos as mgs_can_bet_eos, - mgs.can_bet_bogglepowerball as mgs_can_bet_bogglepowerball, - mgs.created_at as mgs_created_at, - mgs.updated_at as mgs_updated_at, + m_mss.id as m_mss_id, + m_mss.member_id as m_mss_member_id, + m_mss.can_exchange as m_mss_can_exchange, + m_mss.can_first_charge_comp as m_mss_can_first_charge_comp, + m_mss.can_per_charge_comp as m_mss_can_per_charge_comp, + m_mss.manual_payment_type_for_partner as m_mss_manual_payment_type_for_partner, + m_mss.settlement_type as m_mss_settlement_type, + m_mss.rate_casino as m_mss_rate_casino, + m_mss.rate_casino_loosing as m_mss_rate_casino_loosing, + m_mss.rate_casino_bacara as m_mss_rate_casino_bacara, + m_mss.rate_casino_roulette as m_mss_rate_casino_roulette, + m_mss.rate_casino_dragon_tiger as m_mss_rate_casino_dragon_tiger, + m_mss.rate_slot as m_mss_rate_slot, + m_mss.rate_slot_loosing as m_mss_rate_slot_loosing, + m_mss.rate_powerball_single as m_mss_rate_powerball_single, + m_mss.rate_powerball_combo as m_mss_rate_powerball_combo, + m_mss.rate_powerladder_single as m_mss_rate_powerladder_single, + m_mss.rate_powerladder_combo as m_mss_rate_powerladder_combo, + m_mss.rate_eos_single as m_mss_rate_eos_single, + m_mss.rate_eos_combo as m_mss_rate_eos_combo, + m_mss.rate_bogglepowerball_single as m_mss_rate_bogglepowerball_single, + m_mss.rate_bogglepowerball_combo as m_mss_rate_bogglepowerball_combo, + m_mss.created_at as m_mss_created_at, + m_mss.updated_at as m_mss_updated_at, - mss.id as mss_id, - mss.member_id as mss_member_id, - mss.can_exchange as mss_can_exchange, - mss.can_first_charge_comp as mss_can_first_charge_comp, - mss.can_per_charge_comp as mss_can_per_charge_comp, - mss.manual_payment_type_for_partner as mss_manual_payment_type_for_partner, - mss.settlement_type as mss_settlement_type, - mss.rate_casino as mss_rate_casino, - mss.rate_casino_loosing as mss_rate_casino_loosing, - mss.rate_casino_bacara as mss_rate_casino_bacara, - mss.rate_casino_roulette as mss_rate_casino_roulette, - mss.rate_casino_dragon_tiger as mss_rate_casino_dragon_tiger, - mss.rate_slot as mss_rate_slot, - mss.rate_slot_loosing as mss_rate_slot_loosing, - mss.rate_powerball_single as mss_rate_powerball_single, - mss.rate_powerball_combo as mss_rate_powerball_combo, - mss.rate_powerladder_single as mss_rate_powerladder_single, - mss.rate_powerladder_combo as mss_rate_powerladder_combo, - mss.rate_eos_single as mss_rate_eos_single, - mss.rate_eos_combo as mss_rate_eos_combo, - mss.rate_bogglepowerball_single as mss_rate_bogglepowerball_single, - mss.rate_bogglepowerball_combo as mss_rate_bogglepowerball_combo, - mss.created_at as mss_created_at, - mss.updated_at as mss_updated_at, - - mba.id as mba_id, - mba.member_id as mba_member_id, - mba.bank_id as mba_bank_id, - mba.name as mba_name, - mba.account_number as mba_account_number, - mba.exchange_password as mba_exchange_password, - mba.memo as mba_memo, - mba.created_at as mba_created_at, - mba.updated_at as mba_updated_at, + m_mba.id as m_mba_id, + m_mba.member_id as m_mba_member_id, + m_mba.bank_id as m_mba_bank_id, + m_mba.name as m_mba_name, + m_mba.account_number as m_mba_account_number, + m_mba.exchange_password as m_mba_exchange_password, + m_mba.memo as m_mba_memo, + m_mba.created_at as m_mba_created_at, + m_mba.updated_at as m_mba_updated_at, - _b.id as _b_id, - _b.name as _b_name, - _b.sort_order as _b_sort_order, - _b.show as _b_show, - _b.can_use as _b_can_use, - _b.memo as _b_memo, - _b.created_at as _b_created_at, - _b.updated_at as _b_updated_at + m_mba_b.id as m_mba_b_id, + m_mba_b.name as m_mba_b_name, + m_mba_b.sort_order as m_mba_b_sort_order, + m_mba_b.show as m_mba_b_show, + m_mba_b.can_use as m_mba_b_can_use, + m_mba_b.memo as m_mba_b_memo, + m_mba_b.created_at as m_mba_b_created_at, + m_mba_b.updated_at as m_mba_b_updated_at, + + pm.id as pm_id, + pm.site_id as pm_site_id, + pm.member_class_id as pm_member_class_id, + pm.member_level_id as pm_member_level_id, + pm.username as pm_username, + pm.password as pm_password, + pm.nickname as pm_nickname, + pm.mobile_phone_number as pm_mobile_phone_number, + pm.state as pm_state, + pm.state_changed_at as pm_state_changed_at, + pm.parent_member_id as pm_parent_member_id, + pm.child_member_count as pm_child_member_count, + pm.last_signined_ip as pm_last_signined_ip, + pm.last_signined_at as pm_last_signined_at, + pm.created_at as pm_created_at, + pm.updated_at as pm_updated_at, + pm.deleted_at as pm_deleted_at, + + pm_s.id as pm_s_id, + pm_s.url as pm_s_url, + pm_s.name as pm_s_name, + pm_s.path as pm_s_path, + pm_s.show as pm_s_show, + pm_s.can_use as pm_s_can_use, + pm_s.memo as pm_s_memo, + pm_s.expires_at as pm_s_expires_at, + pm_s.created_at as pm_s_created_at, + pm_s.updated_at as pm_s_updated_at, + + pm_mc.id as pm_mc_id, + pm_mc.parent_id as pm_mc_parent_id, + pm_mc.name as pm_mc_name, + pm_mc.show as pm_mc_show, + pm_mc.created_at as pm_mc_created_at, + pm_mc.updated_at as pm_mc_updated_at, + + pm_ml.id as pm_ml_id, + pm_ml.name as pm_ml_name, + pm_ml.show as pm_ml_show, + pm_ml.sort_order as pm_ml_sort_order, + pm_ml.created_at as pm_ml_created_at, + pm_ml.updated_at as pm_ml_updated_at, + + pm_mgs.id as pm_mgs_id, + pm_mgs.member_id as pm_mgs_member_id, + pm_mgs.can_bet_casino as pm_mgs_can_bet_casino, + pm_mgs.can_bet_slot as pm_mgs_can_bet_slot, + pm_mgs.can_bet_powerball as pm_mgs_can_bet_powerball, + pm_mgs.can_bet_powerladder as pm_mgs_can_bet_powerladder, + pm_mgs.can_bet_eos as pm_mgs_can_bet_eos, + pm_mgs.can_bet_bogglepowerball as pm_mgs_can_bet_bogglepowerball, + pm_mgs.created_at as pm_mgs_created_at, + pm_mgs.updated_at as pm_mgs_updated_at, + + pm_mss.id as pm_mss_id, + pm_mss.member_id as pm_mss_member_id, + pm_mss.can_exchange as pm_mss_can_exchange, + pm_mss.can_first_charge_comp as pm_mss_can_first_charge_comp, + pm_mss.can_per_charge_comp as pm_mss_can_per_charge_comp, + pm_mss.manual_payment_type_for_partner as pm_mss_manual_payment_type_for_partner, + pm_mss.settlement_type as pm_mss_settlement_type, + pm_mss.rate_casino as pm_mss_rate_casino, + pm_mss.rate_casino_loosing as pm_mss_rate_casino_loosing, + pm_mss.rate_casino_bacara as pm_mss_rate_casino_bacara, + pm_mss.rate_casino_roulette as pm_mss_rate_casino_roulette, + pm_mss.rate_casino_dragon_tiger as pm_mss_rate_casino_dragon_tiger, + pm_mss.rate_slot as pm_mss_rate_slot, + pm_mss.rate_slot_loosing as pm_mss_rate_slot_loosing, + pm_mss.rate_powerball_single as pm_mss_rate_powerball_single, + pm_mss.rate_powerball_combo as pm_mss_rate_powerball_combo, + pm_mss.rate_powerladder_single as pm_mss_rate_powerladder_single, + pm_mss.rate_powerladder_combo as pm_mss_rate_powerladder_combo, + pm_mss.rate_eos_single as pm_mss_rate_eos_single, + pm_mss.rate_eos_combo as pm_mss_rate_eos_combo, + pm_mss.rate_bogglepowerball_single as pm_mss_rate_bogglepowerball_single, + pm_mss.rate_bogglepowerball_combo as pm_mss_rate_bogglepowerball_combo, + pm_mss.created_at as pm_mss_created_at, + pm_mss.updated_at as pm_mss_updated_at, + + pm_mba.id as pm_mba_id, + pm_mba.member_id as pm_mba_member_id, + pm_mba.bank_id as pm_mba_bank_id, + pm_mba.name as pm_mba_name, + pm_mba.account_number as pm_mba_account_number, + pm_mba.exchange_password as pm_mba_exchange_password, + pm_mba.memo as pm_mba_memo, + pm_mba.created_at as pm_mba_created_at, + pm_mba.updated_at as pm_mba_updated_at, + + pm_mba_b.id as pm_mba_b_id, + pm_mba_b.name as pm_mba_b_name, + pm_mba_b.sort_order as pm_mba_b_sort_order, + pm_mba_b.show as pm_mba_b_show, + pm_mba_b.can_use as pm_mba_b_can_use, + pm_mba_b.memo as pm_mba_b_memo, + pm_mba_b.created_at as pm_mba_b_created_at, + pm_mba_b.updated_at as pm_mba_b_updated_at FROM members as m - INNER JOIN sites s - ON s.id = m.site_id - INNER JOIN member_classes mc - ON mc.id = m.member_class_id - INNER JOIN member_levels ml - ON ml.id = m.member_level_id - LEFT OUTER JOIN members _m - ON _m.id = m.parent_member_id - LEFT OUTER JOIN member_settlement_settings mss - ON mss.member_id = m.id - LEFT OUTER JOIN member_game_settings mgs - ON mgs.member_id = m.id - LEFT OUTER JOIN member_bank_accounts mba - ON mba.member_id = m.id - LEFT OUTER JOIN banks _b - ON _b.id = mba.bank_id -"; + INNER JOIN sites m_s + ON m_s.id = m.site_id + INNER JOIN member_classes m_mc + ON m_mc.id = m.member_class_id + INNER JOIN member_levels m_ml + ON m_ml.id = m.member_level_id + LEFT OUTER JOIN member_settlement_settings m_mss + ON m_mss.member_id = m.id + LEFT OUTER JOIN member_game_settings m_mgs + ON m_mgs.member_id = m.id + LEFT OUTER JOIN member_bank_accounts m_mba + ON m_mba.member_id = m.id + LEFT OUTER JOIN banks m_mba_b + ON m_mba_b.id = m_mba.bank_id + LEFT OUTER JOIN members pm + ON pm.id = m.parent_member_id + LEFT OUTER JOIN sites pm_s + ON pm_s.id = pm.site_id + LEFT OUTER JOIN member_classes pm_mc + ON pm_mc.id = pm.member_class_id + LEFT OUTER JOIN member_levels pm_ml + ON pm_ml.id = pm.member_level_id + LEFT OUTER JOIN member_settlement_settings pm_mss + ON pm_mss.member_id = pm.id + LEFT OUTER JOIN member_game_settings pm_mgs + ON pm_mgs.member_id = pm.id + LEFT OUTER JOIN member_bank_accounts pm_mba + ON pm_mba.member_id = pm.id + LEFT OUTER JOIN banks pm_mba_b + ON pm_mba_b.id = pm_mba.bank_id + "; pub struct Composition {} diff --git a/src/compositions/member/models.rs b/src/compositions/member/models.rs index 148d9d9..78f0708 100644 --- a/src/compositions/member/models.rs +++ b/src/compositions/member/models.rs @@ -1,8 +1,8 @@ //! //! use crate::repositories::{ - bank::models::Bank as _Bank, member::models::Member as _Member, - member::schema::MemberState as _MemberState, member_class::models::MemberClass as _MemberClass, + bank::models::Bank as _Bank, member::schema::MemberState as _MemberState, + member_class::models::MemberClass as _MemberClass, member_game_setting::models::MemberGameSetting as _MemberGameSetting, member_level::models::MemberLevel as _MemberLevel, member_settlement_setting::models::MemberSettlementSetting as _MemberSettlementSetting, @@ -10,6 +10,51 @@ use crate::repositories::{ }; use diesel::deserialize::QueryableByName; +/// +#[derive(PartialEq, PartialOrd, Debug, Clone)] +pub struct ParentMemberModel { + /// + pub id: uuid::Uuid, + /// + pub site: _Site, + /// + pub member_class: _MemberClass, + /// + pub member_level: _MemberLevel, + /// + pub bank_account: Option, + /// + pub username: String, + /// + pub password: String, + /// + pub nickname: String, + /// + pub parent_member_id: Option, + /// + pub child_member_count: i64, + /// + pub mobile_phone_number: Option, + /// + pub state: _MemberState, + /// + pub state_changed_at: Option, + /// + pub member_game_setting: Option<_MemberGameSetting>, + /// + pub member_settlement_setting: Option<_MemberSettlementSetting>, + /// + pub last_signined_ip: Option, + /// + pub last_signined_at: Option, + /// + pub created_at: i64, + /// + pub updated_at: i64, + /// + pub deleted_at: Option, +} + /// #[derive(PartialEq, PartialOrd, Debug, Clone)] pub struct MemberModel { @@ -30,7 +75,7 @@ pub struct MemberModel { /// pub nickname: String, /// - pub parent_member: Option<_Member>, + pub parent_member: Option, /// pub child_member_count: i64, /// @@ -61,148 +106,272 @@ impl QueryableByName for MemberModel { .get::, Option>( "m_parent_member_id", )? { - Some(_) => Some(_Member { - id: row.get("_m_id")?, - site_id: row.get("_m_site_id")?, - member_class_id: row.get("_m_member_class_id")?, - member_level_id: row.get("_m_member_level_id")?, - username: row.get("_m_username")?, - password: row.get("_m_password")?, - nickname: row.get("_m_nickname")?, - mobile_phone_number: row.get("_m_mobile_phone_number")?, - state: row.get("_m_state")?, - state_changed_at: row.get("_m_state_changed_at")?, - parent_member_id: row.get("_m_parent_member_id")?, - child_member_count: row.get("_m_child_member_count")?, - last_signined_ip: row.get("_m_last_signined_ip")?, - last_signined_at: row.get("_m_last_signined_at")?, - created_at: row.get("_m_created_at")?, - updated_at: row.get("_m_updated_at")?, - deleted_at: row.get("_m_deleted_at")?, - }), + Some(_) => { + let site = _Site { + id: row.get("pm_s_id")?, + url: row.get("pm_s_url")?, + name: row.get("pm_s_name")?, + path: row.get("pm_s_path")?, + show: row.get("pm_s_show")?, + can_use: row.get("pm_s_can_use")?, + memo: row.get("pm_s_memo")?, + expires_at: row.get("pm_s_expires_at")?, + created_at: row.get("pm_s_created_at")?, + updated_at: row.get("pm_s_updated_at")?, + }; + + let member_class = _MemberClass { + id: row.get("pm_mc_id")?, + parent_id: row.get("pm_mc_parent_id")?, + name: row.get("pm_mc_name")?, + show: row.get("pm_mc_show")?, + created_at: row.get("pm_mc_created_at")?, + updated_at: row.get("pm_mc_updated_at")?, + }; + + let member_level = _MemberLevel { + id: row.get("pm_ml_id")?, + name: row.get("pm_ml_name")?, + show: row.get("pm_ml_show")?, + sort_order: row.get("pm_ml_sort_order")?, + created_at: row.get("pm_ml_created_at")?, + updated_at: row.get("pm_ml_updated_at")?, + }; + + let member_game_setting = match row + .get::, Option>( + "pm_mgs_id", + )? { + Some(_) => Some(_MemberGameSetting { + id: row.get("pm_mgs_id")?, + member_id: row.get("pm_mgs_member_id")?, + can_bet_casino: row.get("pm_mgs_can_bet_casino")?, + can_bet_slot: row.get("pm_mgs_can_bet_slot")?, + can_bet_powerball: row.get("pm_mgs_can_bet_powerball")?, + can_bet_powerladder: row.get("pm_mgs_can_bet_powerladder")?, + can_bet_eos: row.get("pm_mgs_can_bet_eos")?, + can_bet_bogglepowerball: row.get("pm_mgs_can_bet_bogglepowerball")?, + created_at: row.get("pm_mgs_created_at")?, + updated_at: row.get("pm_mgs_updated_at")?, + }), + None => None, + }; + + let member_settlement_setting = match row.get::, Option>("pm_mss_id")? + { + Some(_) => Some(_MemberSettlementSetting { + id: row.get("pm_mss_id")?, + member_id: row.get("pm_mss_member_id")?, + can_exchange: row.get("pm_mss_can_exchange")?, + can_first_charge_comp: row.get("pm_mss_can_first_charge_comp")?, + can_per_charge_comp: row.get("pm_mss_can_per_charge_comp")?, + manual_payment_type_for_partner: row.get("pm_mss_manual_payment_type_for_partner")?, + settlement_type: row.get("pm_mss_settlement_type")?, + rate_casino: row.get("pm_mss_rate_casino")?, + rate_casino_loosing: row.get("pm_mss_rate_casino_loosing")?, + rate_casino_bacara: row.get("pm_mss_rate_casino_bacara")?, + rate_casino_roulette: row.get("pm_mss_rate_casino_roulette")?, + rate_casino_dragon_tiger: row.get("pm_mss_rate_casino_dragon_tiger")?, + rate_slot: row.get("pm_mss_rate_slot")?, + rate_slot_loosing: row.get("pm_mss_rate_slot_loosing")?, + rate_powerball_single: row.get("pm_mss_rate_powerball_single")?, + rate_powerball_combo: row.get("pm_mss_rate_powerball_combo")?, + rate_powerladder_single: row.get("pm_mss_rate_powerladder_single")?, + rate_powerladder_combo: row.get("pm_mss_rate_powerladder_combo")?, + rate_eos_single: row.get("pm_mss_rate_eos_single")?, + rate_eos_combo: row.get("pm_mss_rate_eos_combo")?, + rate_bogglepowerball_single: row.get("pm_mss_rate_bogglepowerball_single")?, + rate_bogglepowerball_combo: row.get("pm_mss_rate_bogglepowerball_combo")?, + created_at: row.get("pm_mss_created_at")?, + updated_at: row.get("pm_mss_updated_at")?, + }), + None => None, + }; + + let member_bank_account = match row + .get::, Option>( + "pm_mba_id", + )? { + Some(_) => { + let bank = _Bank { + id: row.get("pm_mba_b_id")?, + name: row.get("pm_mba_b_name")?, + sort_order: row.get("pm_mba_b_sort_order")?, + show: row.get("pm_mba_b_show")?, + can_use: row.get("pm_mba_b_can_use")?, + memo: row.get("pm_mba_b_memo")?, + created_at: row.get("pm_mba_b_created_at")?, + updated_at: row.get("pm_mba_b_updated_at")?, + }; + + Some(MemberBankAccountModel { + id: row.get("pm_mba_id")?, + member_id: row.get("pm_mba_member_id")?, + bank, + name: row.get("pm_mba_name")?, + account_number: row.get("pm_mba_account_number")?, + exchange_password: row.get("pm_mba_exchange_password")?, + memo: row.get("pm_mba_memo")?, + created_at: row.get("pm_mba_created_at")?, + updated_at: row.get("pm_mba_updated_at")?, + }) + } + None => None, + }; + + Some(ParentMemberModel { + id: row.get("pm_id")?, + site, + member_class, + member_level, + username: row.get("pm_username")?, + password: row.get("pm_password")?, + nickname: row.get("pm_nickname")?, + mobile_phone_number: row.get("pm_mobile_phone_number")?, + state: row.get("pm_state")?, + state_changed_at: row.get("pm_state_changed_at")?, + parent_member_id: row.get("pm_parent_member_id")?, + child_member_count: row.get("pm_child_member_count")?, + member_game_setting, + member_settlement_setting, + bank_account: member_bank_account, + last_signined_ip: row.get("pm_last_signined_ip")?, + last_signined_at: row.get("pm_last_signined_at")?, + created_at: row.get("pm_created_at")?, + updated_at: row.get("pm_updated_at")?, + deleted_at: row.get("pm_deleted_at")?, + }) + } None => None, }; - let bank = match row - .get::, Option>("_b_id")? - { - Some(_) => Some(_Bank { - id: row.get("_b_id")?, - name: row.get("_b_name")?, - sort_order: row.get("_b_sort_order")?, - show: row.get("_b_show")?, - can_use: row.get("_b_can_use")?, - memo: row.get("_b_memo")?, - created_at: row.get("_b_created_at")?, - updated_at: row.get("_b_updated_at")?, - }), - None => None, + let site = _Site { + id: row.get("m_s_id")?, + url: row.get("m_s_url")?, + name: row.get("m_s_name")?, + path: row.get("m_s_path")?, + show: row.get("m_s_show")?, + can_use: row.get("m_s_can_use")?, + memo: row.get("m_s_memo")?, + expires_at: row.get("m_s_expires_at")?, + created_at: row.get("m_s_created_at")?, + updated_at: row.get("m_s_updated_at")?, }; - let member_bank_account = match bank { - Some(bank) => Some(MemberBankAccountModel { - id: row.get("mba_id")?, - member_id: row.get("mba_member_id")?, - bank, - name: row.get("mba_name")?, - account_number: row.get("mba_account_number")?, - exchange_password: row.get("mba_exchange_password")?, - memo: row.get("mba_memo")?, - created_at: row.get("mba_created_at")?, - updated_at: row.get("mba_updated_at")?, - }), - None => None, + let member_class = _MemberClass { + id: row.get("m_mc_id")?, + parent_id: row.get("m_mc_parent_id")?, + name: row.get("m_mc_name")?, + show: row.get("m_mc_show")?, + created_at: row.get("m_mc_created_at")?, + updated_at: row.get("m_mc_updated_at")?, + }; + + let member_level = _MemberLevel { + id: row.get("m_ml_id")?, + name: row.get("m_ml_name")?, + show: row.get("m_ml_show")?, + sort_order: row.get("m_ml_sort_order")?, + created_at: row.get("m_ml_created_at")?, + updated_at: row.get("m_ml_updated_at")?, }; let member_game_setting = match row - .get::, Option>("mgs_id")? + .get::, Option>("m_mgs_id")? { Some(_) => Some(_MemberGameSetting { - id: row.get("mgs_id")?, - member_id: row.get("mgs_member_id")?, - can_bet_casino: row.get("mgs_can_bet_casino")?, - can_bet_slot: row.get("mgs_can_bet_slot")?, - can_bet_powerball: row.get("mgs_can_bet_powerball")?, - can_bet_powerladder: row.get("mgs_can_bet_powerladder")?, - can_bet_eos: row.get("mgs_can_bet_eos")?, - can_bet_bogglepowerball: row.get("mgs_can_bet_bogglepowerball")?, - created_at: row.get("mgs_created_at")?, - updated_at: row.get("mgs_updated_at")?, + id: row.get("m_mgs_id")?, + member_id: row.get("m_mgs_member_id")?, + can_bet_casino: row.get("m_mgs_can_bet_casino")?, + can_bet_slot: row.get("m_mgs_can_bet_slot")?, + can_bet_powerball: row.get("m_mgs_can_bet_powerball")?, + can_bet_powerladder: row.get("m_mgs_can_bet_powerladder")?, + can_bet_eos: row.get("m_mgs_can_bet_eos")?, + can_bet_bogglepowerball: row.get("m_mgs_can_bet_bogglepowerball")?, + created_at: row.get("m_mgs_created_at")?, + updated_at: row.get("m_mgs_updated_at")?, }), None => None, }; let member_settlement_setting = match row - .get::, Option>("mss_id")? + .get::, Option>("m_mss_id")? { Some(_) => Some(_MemberSettlementSetting { - id: row.get("mss_id")?, - member_id: row.get("mss_member_id")?, - can_exchange: row.get("mss_can_exchange")?, - can_first_charge_comp: row.get("mss_can_first_charge_comp")?, - can_per_charge_comp: row.get("mss_can_per_charge_comp")?, - manual_payment_type_for_partner: row.get("mss_manual_payment_type_for_partner")?, - settlement_type: row.get("mss_settlement_type")?, - rate_casino: row.get("mss_rate_casino")?, - rate_casino_loosing: row.get("mss_rate_casino_loosing")?, - rate_casino_bacara: row.get("mss_rate_casino_bacara")?, - rate_casino_roulette: row.get("mss_rate_casino_roulette")?, - rate_casino_dragon_tiger: row.get("mss_rate_casino_dragon_tiger")?, - rate_slot: row.get("mss_rate_slot")?, - rate_slot_loosing: row.get("mss_rate_slot_loosing")?, - rate_powerball_single: row.get("mss_rate_powerball_single")?, - rate_powerball_combo: row.get("mss_rate_powerball_combo")?, - rate_powerladder_single: row.get("mss_rate_powerladder_single")?, - rate_powerladder_combo: row.get("mss_rate_powerladder_combo")?, - rate_eos_single: row.get("mss_rate_eos_single")?, - rate_eos_combo: row.get("mss_rate_eos_combo")?, - rate_bogglepowerball_single: row.get("mss_rate_bogglepowerball_single")?, - rate_bogglepowerball_combo: row.get("mss_rate_bogglepowerball_combo")?, - created_at: row.get("mss_created_at")?, - updated_at: row.get("mss_updated_at")?, + id: row.get("m_mss_id")?, + member_id: row.get("m_mss_member_id")?, + can_exchange: row.get("m_mss_can_exchange")?, + can_first_charge_comp: row.get("m_mss_can_first_charge_comp")?, + can_per_charge_comp: row.get("m_mss_can_per_charge_comp")?, + manual_payment_type_for_partner: row.get("m_mss_manual_payment_type_for_partner")?, + settlement_type: row.get("m_mss_settlement_type")?, + rate_casino: row.get("m_mss_rate_casino")?, + rate_casino_loosing: row.get("m_mss_rate_casino_loosing")?, + rate_casino_bacara: row.get("m_mss_rate_casino_bacara")?, + rate_casino_roulette: row.get("m_mss_rate_casino_roulette")?, + rate_casino_dragon_tiger: row.get("m_mss_rate_casino_dragon_tiger")?, + rate_slot: row.get("m_mss_rate_slot")?, + rate_slot_loosing: row.get("m_mss_rate_slot_loosing")?, + rate_powerball_single: row.get("m_mss_rate_powerball_single")?, + rate_powerball_combo: row.get("m_mss_rate_powerball_combo")?, + rate_powerladder_single: row.get("m_mss_rate_powerladder_single")?, + rate_powerladder_combo: row.get("m_mss_rate_powerladder_combo")?, + rate_eos_single: row.get("m_mss_rate_eos_single")?, + rate_eos_combo: row.get("m_mss_rate_eos_combo")?, + rate_bogglepowerball_single: row.get("m_mss_rate_bogglepowerball_single")?, + rate_bogglepowerball_combo: row.get("m_mss_rate_bogglepowerball_combo")?, + created_at: row.get("m_mss_created_at")?, + updated_at: row.get("m_mss_updated_at")?, }), None => None, }; + let member_bank_account = match row + .get::, Option>("m_mba_id")? + { + Some(_) => { + let bank = _Bank { + id: row.get("m_mba_b_id")?, + name: row.get("m_mba_b_name")?, + sort_order: row.get("m_mba_b_sort_order")?, + show: row.get("m_mba_b_show")?, + can_use: row.get("m_mba_b_can_use")?, + memo: row.get("m_mba_b_memo")?, + created_at: row.get("m_mba_b_created_at")?, + updated_at: row.get("m_mba_b_updated_at")?, + }; + + Some(MemberBankAccountModel { + id: row.get("m_mba_id")?, + member_id: row.get("m_mba_member_id")?, + bank, + name: row.get("m_mba_name")?, + account_number: row.get("m_mba_account_number")?, + exchange_password: row.get("m_mba_exchange_password")?, + memo: row.get("m_mba_memo")?, + created_at: row.get("m_mba_created_at")?, + updated_at: row.get("m_mba_updated_at")?, + }) + } + None => None, + }; + Ok(MemberModel { id: row.get("m_id")?, - site: _Site { - id: row.get("s_id")?, - url: row.get("s_url")?, - name: row.get("s_name")?, - path: row.get("s_path")?, - show: row.get("s_show")?, - can_use: row.get("s_can_use")?, - memo: row.get("s_memo")?, - expires_at: row.get("s_expires_at")?, - created_at: row.get("s_created_at")?, - updated_at: row.get("s_updated_at")?, - }, - member_class: _MemberClass { - id: row.get("mc_id")?, - parent_id: row.get("mc_parent_id")?, - name: row.get("mc_name")?, - show: row.get("mc_show")?, - created_at: row.get("mc_created_at")?, - updated_at: row.get("mc_updated_at")?, - }, - member_level: _MemberLevel { - id: row.get("ml_id")?, - name: row.get("ml_name")?, - show: row.get("ml_show")?, - sort_order: row.get("ml_sort_order")?, - created_at: row.get("ml_created_at")?, - updated_at: row.get("ml_updated_at")?, - }, + site, + member_class, + member_level, username: row.get("m_username")?, password: row.get("m_password")?, nickname: row.get("m_nickname")?, mobile_phone_number: row.get("m_mobile_phone_number")?, state: row.get("m_state")?, state_changed_at: row.get("m_state_changed_at")?, - bank_account: member_bank_account, member_game_setting, member_settlement_setting, + bank_account: member_bank_account, parent_member, child_member_count: row.get("m_child_member_count")?, last_signined_ip: row.get("m_last_signined_ip")?, diff --git a/src/services/member/models.rs b/src/services/member/models.rs index 77af1f2..34f6219 100644 --- a/src/services/member/models.rs +++ b/src/services/member/models.rs @@ -51,9 +51,11 @@ impl From<&repositories::member::models::Member> for bpr::models::member::Member } } -impl From<&compositions::member::models::MemberModel> for bpr::models::member::MemberModel { - fn from(d: &compositions::member::models::MemberModel) -> Self { - bpr::models::member::MemberModel { +impl From<&compositions::member::models::ParentMemberModel> + for bpr::models::member::ParentMemberModel +{ + fn from(d: &compositions::member::models::ParentMemberModel) -> Self { + bpr::models::member::ParentMemberModel { id: d.id.to_string(), site: Some(bpr::models::site::Site::from(&d.site)), member_class: Some(bpr::models::member_class::MemberClass::from( @@ -66,10 +68,49 @@ impl From<&compositions::member::models::MemberModel> for bpr::models::member::M .bank_account .as_ref() .map(bpr::models::member_bank_account::MemberBankAccountModel::from), - parent_member: d - .parent_member - .as_ref() - .map(bpr::models::member::Member::from), + parent_member_id: d.parent_member_id.map(|v| v.to_string()), + child_member_count: d.child_member_count as u64, + username: d.username.clone(), + nickname: d.nickname.clone(), + mobile_phone_number: d.mobile_phone_number.clone(), + state: d.state as i32, + state_changed_at: d.state_changed_at.map(|d| d as u64), + member_game_setting: d + .member_game_setting + .as_ref() + .map(bpr::models::member_game_setting::MemberGameSetting::from), + member_settlement_setting: d + .member_settlement_setting + .as_ref() + .map(bpr::models::member_settlement_setting::MemberSettlementSetting::from), + last_signined_ip: d.last_signined_ip.clone(), + last_signined_at: d.last_signined_at.map(|d| d as u64), + created_at: d.created_at as u64, + updated_at: d.updated_at as u64, + deleted_at: d.deleted_at.map(|d| d as u64), + } + } +} + +impl From<&compositions::member::models::MemberModel> for bpr::models::member::MemberModel { + fn from(d: &compositions::member::models::MemberModel) -> Self { + bpr::models::member::MemberModel { + id: d.id.to_string(), + site: Some(bpr::models::site::Site::from(&d.site)), + member_class: Some(bpr::models::member_class::MemberClass::from( + &d.member_class, + )), + member_level: Some(bpr::models::member_level::MemberLevel::from( + &d.member_level, + )), + bank_account: d + .bank_account + .as_ref() + .map(bpr::models::member_bank_account::MemberBankAccountModel::from), + parent_member: d + .parent_member + .as_ref() + .map(bpr::models::member::ParentMemberModel::from), child_member_count: d.child_member_count as u64, username: d.username.clone(), nickname: d.nickname.clone(),