From cd36f9eadadb362eb3c56f7cc4cd5db112625a6c Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Mon, 29 Aug 2022 04:01:16 +0000 Subject: [PATCH] refactoring --- Cargo.toml | 4 ++-- migrations/202208061300_api_kgon_game/down.sql | 2 +- migrations/202208061300_api_kgon_game/up.sql | 8 ++++---- src/repositories/game/models.rs | 8 ++++---- src/repositories/game/repository.rs | 18 +++++++++--------- src/repositories/game/schema.rs | 2 +- src/services/game/models.rs | 2 +- src/services/game/service.rs | 2 +- src/synchronizations/game/synchronizer.rs | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b8f83f0..8bcccd3 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.79-snapshot" } -beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.65-snapshot" } +beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.80-snapshot" } +beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.66-snapshot" } [build-dependencies] diff --git a/migrations/202208061300_api_kgon_game/down.sql b/migrations/202208061300_api_kgon_game/down.sql index b369db3..12237e8 100644 --- a/migrations/202208061300_api_kgon_game/down.sql +++ b/migrations/202208061300_api_kgon_game/down.sql @@ -1,4 +1,4 @@ -DROP INDEX idx_api_kgon_games_vendor_id; +DROP INDEX idx_api_kgon_games_kgon_vendor_id; DROP INDEX idx_api_kgon_games_key; DROP INDEX idx_api_kgon_games_category; DROP INDEX idx_api_kgon_games_game_type; diff --git a/migrations/202208061300_api_kgon_game/up.sql b/migrations/202208061300_api_kgon_game/up.sql index 57aa603..d3bf6e5 100644 --- a/migrations/202208061300_api_kgon_game/up.sql +++ b/migrations/202208061300_api_kgon_game/up.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS api_kgon_games ( id BIGINT NOT NULL, - vendor_id BIGINT NOT NULL, + kgon_vendor_id BIGINT NOT NULL, key TEXT NOT NULL, names TEXT NOT NULL, platform TEXT NOT NULL, @@ -10,12 +10,12 @@ CREATE TABLE IF NOT EXISTS api_kgon_games ( created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), PRIMARY KEY (id), - CONSTRAINT fk_api_kgon_games_vendor_id - FOREIGN KEY(vendor_id) + CONSTRAINT fk_api_kgon_games_kgon_vendor_id + FOREIGN KEY(kgon_vendor_id) REFERENCES api_kgon_vendors(id) ); -CREATE INDEX idx_api_kgon_games_vendor_id ON api_kgon_games (vendor_id); +CREATE INDEX idx_api_kgon_games_kgon_vendor_id ON api_kgon_games (kgon_vendor_id); CREATE INDEX idx_api_kgon_games_key ON api_kgon_games (key); CREATE INDEX idx_api_kgon_games_category ON api_kgon_games (category); CREATE INDEX idx_api_kgon_games_game_type ON api_kgon_games (game_type); diff --git a/src/repositories/game/models.rs b/src/repositories/game/models.rs index 39f36e1..1c81a91 100644 --- a/src/repositories/game/models.rs +++ b/src/repositories/game/models.rs @@ -8,7 +8,7 @@ pub struct Game { /// pub id: i64, /// - pub vendor_id: i64, + pub kgon_vendor_id: i64, /// pub key: String, /// @@ -34,7 +34,7 @@ pub struct NewGame { /// pub id: i64, /// - pub vendor_id: i64, + pub kgon_vendor_id: i64, /// pub key: String, /// @@ -74,7 +74,7 @@ pub struct UpsertGame { /// pub id: i64, /// - pub vendor_id: i64, + pub kgon_vendor_id: i64, /// pub key: String, /// @@ -93,7 +93,7 @@ pub struct UpsertGame { #[derive(Debug, Clone)] pub struct FindAllSearch { /// - pub vendor_id: Option, + pub kgon_vendor_id: Option, /// pub key_like: Option, /// diff --git a/src/repositories/game/repository.rs b/src/repositories/game/repository.rs index a5f8d31..667cd72 100644 --- a/src/repositories/game/repository.rs +++ b/src/repositories/game/repository.rs @@ -53,7 +53,7 @@ impl Repository { .on_conflict(dsl::id) .do_update() .set(( - dsl::vendor_id.eq(excluded(dsl::vendor_id)), + dsl::kgon_vendor_id.eq(excluded(dsl::kgon_vendor_id)), dsl::key.eq(excluded(dsl::key)), dsl::names.eq(excluded(dsl::names)), dsl::platform.eq(excluded(dsl::platform)), @@ -90,8 +90,8 @@ impl Repository { let mut q = api_kgon_games::table.into_boxed(); if let Some(s) = &find_all.search { - if let Some(sp) = s.vendor_id { - q = q.filter(api_kgon_games::dsl::vendor_id.eq(sp)); + if let Some(sp) = s.kgon_vendor_id { + q = q.filter(api_kgon_games::dsl::kgon_vendor_id.eq(sp)); } if let Some(sp) = &s.key_like { q = q.filter(api_kgon_games::dsl::key.like(sp)); @@ -119,8 +119,8 @@ impl Repository { let mut q = api_kgon_games::table.into_boxed(); if let Some(s) = &find_all.search { - if let Some(sp) = s.vendor_id { - q = q.filter(api_kgon_games::dsl::vendor_id.eq(sp)); + if let Some(sp) = s.kgon_vendor_id { + q = q.filter(api_kgon_games::dsl::kgon_vendor_id.eq(sp)); } if let Some(sp) = &s.key_like { q = q.filter(api_kgon_games::dsl::key.like(sp)); @@ -148,8 +148,8 @@ impl Repository { for s in orderbys { match s { bcr::pagination::Sort::ASC(property) => match property.as_str() { - "vendor_id" => { - q = q.order_by(api_kgon_games::vendor_id.asc()); + "kgon_vendor_id" => { + q = q.order_by(api_kgon_games::kgon_vendor_id.asc()); } "key" => { q = q.order_by(api_kgon_games::key.asc()); @@ -172,8 +172,8 @@ impl Repository { _ => {} }, bcr::pagination::Sort::DESC(property) => match property.as_str() { - "vendor_id" => { - q = q.order_by(api_kgon_games::vendor_id.desc()); + "kgon_vendor_id" => { + q = q.order_by(api_kgon_games::kgon_vendor_id.desc()); } "key" => { q = q.order_by(api_kgon_games::key.desc()); diff --git a/src/repositories/game/schema.rs b/src/repositories/game/schema.rs index 4d5a2e0..60eefc0 100644 --- a/src/repositories/game/schema.rs +++ b/src/repositories/game/schema.rs @@ -7,7 +7,7 @@ table! { /// id -> BigInt, /// - vendor_id -> BigInt, + kgon_vendor_id -> BigInt, /// key -> Text, /// diff --git a/src/services/game/models.rs b/src/services/game/models.rs index cf60305..7b58766 100644 --- a/src/services/game/models.rs +++ b/src/services/game/models.rs @@ -6,7 +6,7 @@ impl From<&repositories::game::models::Game> for bpr::models::api::game::Game { bpr::models::api::game::Game { id: d.id as u64, key: d.key.clone(), - vendor_id: d.vendor_id as u64, + kgon_vendor_id: d.kgon_vendor_id as u64, names: d.names.clone(), platform: d.platform.clone(), game_type: d.game_type.clone(), diff --git a/src/services/game/service.rs b/src/services/game/service.rs index 3f339a8..bf2a93d 100644 --- a/src/services/game/service.rs +++ b/src/services/game/service.rs @@ -104,7 +104,7 @@ impl Service { let find_all = repositories::game::models::FindAll { search: match request.search { Some(s) => Some(repositories::game::models::FindAllSearch { - vendor_id: s.vendor_id.map(|d| d as i64), + kgon_vendor_id: s.kgon_vendor_id.map(|d| d as i64), key_like: s.key_like, category_like: s.category_like, platform_like: s.platform_like, diff --git a/src/synchronizations/game/synchronizer.rs b/src/synchronizations/game/synchronizer.rs index 63beac1..11d6653 100644 --- a/src/synchronizations/game/synchronizer.rs +++ b/src/synchronizations/game/synchronizer.rs @@ -90,7 +90,7 @@ impl Synchronizer { upsert_games.push(repositories::game::models::UpsertGame { id: g.id, - vendor_id: v.id, + kgon_vendor_id: v.id, key: g.key.clone(), names: serde_json::to_string(&g.names).expect("names"), platform: g.platform.clone(),