From f828b707a95319b390253eb91784b2ca7fb53153 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Thu, 1 Sep 2022 09:44:16 +0000 Subject: [PATCH] model is modified --- Cargo.toml | 4 +- src/compositions/betting/composition.rs | 64 +++++++++++++------------ src/compositions/betting/models.rs | 20 +------- src/services/betting/models.rs | 14 +----- src/services/betting/service.rs | 4 +- 5 files changed, 41 insertions(+), 65 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e725f03..64668c9 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/betting/composition.rs b/src/compositions/betting/composition.rs index 991f557..57fb3f2 100644 --- a/src/compositions/betting/composition.rs +++ b/src/compositions/betting/composition.rs @@ -3,15 +3,15 @@ use beteran_common_rust as bcr; use diesel::{result::Error, sql_query, RunQueryDsl}; use std::fmt::Write; -static MEMBER_COUNT_QUERY: &str = " +static BETTING_HISTORY_COUNT_QUERY: &str = " SELECT COUNT(akbh.id) FROM api_kgon_betting_history as akbh - INNER JOIN members _m - ON _m.username = akbh.site_username + INNER JOIN members m + ON m.username = akbh.site_username "; -static MEMBER_QUERY: &str = " +static BETTING_HISTORY_QUERY: &str = " SELECT akbh.id as akbh_id , akbh.vendor_id as akbh_vendor_id , @@ -37,27 +37,29 @@ SELECT akbh.created_at as akbh_created_at , akbh.utc_created_at as akbh_utc_created_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.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 + FROM api_kgon_betting_history as akbh - INNER JOIN members _m - ON _m.username = akbh.site_username + INNER JOIN members m + ON m.username = akbh.site_username + "; pub struct Composition {} @@ -86,7 +88,7 @@ impl Composition { WHERE akbh.id = $1 ", - MEMBER_QUERY + BETTING_HISTORY_QUERY ); match sql_query(query) @@ -113,7 +115,7 @@ impl Composition { WHERE m.id = $1 ", - MEMBER_QUERY + BETTING_HISTORY_QUERY ); match sql_query(query) @@ -163,9 +165,9 @@ impl Composition { }; let property = match property.as_str() { - "member_id" => "_m.id".to_string(), - "username" => "_m.username".to_string(), - "nickname" => "_m.nickname".to_string(), + "member_id" => "m.id".to_string(), + "username" => "m.username".to_string(), + "nickname" => "m.nickname".to_string(), "vendor_id" => "akbh.vendor_id".to_string(), "vendor_name" => "akbh.vendor_name".to_string(), "game_id" => "akbh.game_id".to_string(), @@ -210,7 +212,7 @@ impl Composition { write!(&mut query_where, " AND ") .map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?; } - write!(&mut query_where, "_m.id = '{}'", sp) + write!(&mut query_where, "m.id = '{}'", sp) .map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?; } @@ -514,7 +516,7 @@ impl Composition { } let mut query = String::new(); - write!(&mut query, "{}", MEMBER_COUNT_QUERY) + write!(&mut query, "{}", BETTING_HISTORY_COUNT_QUERY) .map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?; let query_where = self.get_find_all(find_all)?; @@ -541,7 +543,7 @@ impl Composition { find_all: &models::FindAll, ) -> Result, Error> { let mut query = String::new(); - write!(&mut query, "{}", MEMBER_QUERY) + write!(&mut query, "{}", BETTING_HISTORY_QUERY) .map_err(|e| diesel::result::Error::QueryBuilderError(e.to_string().into()))?; let query_where = self.get_find_all(find_all)?; diff --git a/src/compositions/betting/models.rs b/src/compositions/betting/models.rs index 4994edc..cb57962 100644 --- a/src/compositions/betting/models.rs +++ b/src/compositions/betting/models.rs @@ -50,18 +50,6 @@ pub struct BettingHistoryModel { pub created_at: i64, /// pub utc_created_at: i64, - /// - pub m_site_id: uuid::Uuid, - /// - pub m_member_class_id: uuid::Uuid, - /// - pub m_member_level_id: uuid::Uuid, - /// - pub m_parent_member_id: Option, - /// - pub m_nickname: String, - /// - pub m_mobile_phone_number: Option, } impl QueryableByName for BettingHistoryModel { @@ -90,12 +78,6 @@ impl QueryableByName for BettingHistoryModel { category: row.get("akbh_category")?, created_at: row.get("akbh_created_at")?, utc_created_at: row.get("akbh_utc_created_at")?, - m_site_id: row.get("_m_site_id")?, - m_member_class_id: row.get("_m_member_class_id")?, - m_member_level_id: row.get("_m_member_level_id")?, - m_nickname: row.get("_m_nickname")?, - m_mobile_phone_number: row.get("_m_mobile_phone_number")?, - m_parent_member_id: row.get("_m_parent_member_id")?, }) } } @@ -177,3 +159,5 @@ pub struct FindAll { /// pub sorts: Option>, } + +/////////////////////////////// temparary definitions /////////////////////////////////////////// diff --git a/src/services/betting/models.rs b/src/services/betting/models.rs index 48fe854..5145f95 100644 --- a/src/services/betting/models.rs +++ b/src/services/betting/models.rs @@ -2,19 +2,10 @@ use crate::compositions; use beteran_protobuf_rust as bpr; impl From<&compositions::betting::models::BettingHistoryModel> - for bpr::models::api::betting::BettingHistoryModel + for bpr::models::api::betting::BettingHistory { fn from(d: &compositions::betting::models::BettingHistoryModel) -> Self { - let member = Some(bpr::models::api::betting::betting_history_model::Member { - site_id: d.m_site_id.to_string(), - member_class_id: d.m_member_class_id.to_string(), - member_level_id: d.m_member_level_id.to_string(), - parent_member_id: d.m_parent_member_id.map(|v| v.to_string()), - nickname: d.m_nickname.clone(), - mobile_phone_number: d.m_mobile_phone_number.clone(), - }); - - bpr::models::api::betting::BettingHistoryModel { + bpr::models::api::betting::BettingHistory { id: d.id.clone(), vendor_id: d.vendor_id as u64, vendor_name: d.vendor_name.clone(), @@ -38,7 +29,6 @@ impl From<&compositions::betting::models::BettingHistoryModel> category: d.category.clone(), created_at: d.created_at as u64, utc_created_at: d.utc_created_at as u64, - member, } } } diff --git a/src/services/betting/service.rs b/src/services/betting/service.rs index dfc5430..cdd8029 100644 --- a/src/services/betting/service.rs +++ b/src/services/betting/service.rs @@ -29,7 +29,7 @@ impl Service { pool: Pool>, ) -> Service { Service { - connection_broker: connection_broker.clone(), + connection_broker, queue_broker, pool, betting_composition: compositions::betting::composition::Composition::new(), @@ -188,7 +188,7 @@ impl Service { bpr::ss::api::betting::list_betting_history_response::Result { betting_history: list .iter() - .map(bpr::models::api::betting::BettingHistoryModel::from) + .map(bpr::models::api::betting::BettingHistory::from) .collect(), }, ),