refactoring

This commit is contained in:
병준 박 2022-08-29 04:14:38 +00:00
parent cd36f9eada
commit 3ad73b26d3
9 changed files with 24 additions and 24 deletions

View File

@ -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.80-snapshot" }
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.66-snapshot" }
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.81-snapshot" }
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.67-snapshot" }
[build-dependencies]

View File

@ -1,4 +1,4 @@
DROP INDEX idx_api_kgon_games_kgon_vendor_id;
DROP INDEX idx_api_kgon_games_parent_id;
DROP INDEX idx_api_kgon_games_key;
DROP INDEX idx_api_kgon_games_category;
DROP INDEX idx_api_kgon_games_game_type;

View File

@ -1,6 +1,6 @@
CREATE TABLE IF NOT EXISTS api_kgon_games (
id BIGINT NOT NULL,
kgon_vendor_id BIGINT NOT NULL,
parent_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_kgon_vendor_id
FOREIGN KEY(kgon_vendor_id)
CONSTRAINT fk_api_kgon_games_parent_id
FOREIGN KEY(parent_id)
REFERENCES api_kgon_vendors(id)
);
CREATE INDEX idx_api_kgon_games_kgon_vendor_id ON api_kgon_games (kgon_vendor_id);
CREATE INDEX idx_api_kgon_games_parent_id ON api_kgon_games (parent_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);

View File

@ -8,7 +8,7 @@ pub struct Game {
///
pub id: i64,
///
pub kgon_vendor_id: i64,
pub parent_id: i64,
///
pub key: String,
///
@ -34,7 +34,7 @@ pub struct NewGame {
///
pub id: i64,
///
pub kgon_vendor_id: i64,
pub parent_id: i64,
///
pub key: String,
///
@ -74,7 +74,7 @@ pub struct UpsertGame {
///
pub id: i64,
///
pub kgon_vendor_id: i64,
pub parent_id: i64,
///
pub key: String,
///
@ -93,7 +93,7 @@ pub struct UpsertGame {
#[derive(Debug, Clone)]
pub struct FindAllSearch {
///
pub kgon_vendor_id: Option<i64>,
pub parent_id: Option<i64>,
///
pub key_like: Option<String>,
///

View File

@ -53,7 +53,7 @@ impl Repository {
.on_conflict(dsl::id)
.do_update()
.set((
dsl::kgon_vendor_id.eq(excluded(dsl::kgon_vendor_id)),
dsl::parent_id.eq(excluded(dsl::parent_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.kgon_vendor_id {
q = q.filter(api_kgon_games::dsl::kgon_vendor_id.eq(sp));
if let Some(sp) = s.parent_id {
q = q.filter(api_kgon_games::dsl::parent_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.kgon_vendor_id {
q = q.filter(api_kgon_games::dsl::kgon_vendor_id.eq(sp));
if let Some(sp) = s.parent_id {
q = q.filter(api_kgon_games::dsl::parent_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() {
"kgon_vendor_id" => {
q = q.order_by(api_kgon_games::kgon_vendor_id.asc());
"parent_id" => {
q = q.order_by(api_kgon_games::parent_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() {
"kgon_vendor_id" => {
q = q.order_by(api_kgon_games::kgon_vendor_id.desc());
"parent_id" => {
q = q.order_by(api_kgon_games::parent_id.desc());
}
"key" => {
q = q.order_by(api_kgon_games::key.desc());

View File

@ -7,7 +7,7 @@ table! {
///
id -> BigInt,
///
kgon_vendor_id -> BigInt,
parent_id -> BigInt,
///
key -> Text,
///

View File

@ -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(),
kgon_vendor_id: d.kgon_vendor_id as u64,
parent_id: d.parent_id as u64,
names: d.names.clone(),
platform: d.platform.clone(),
game_type: d.game_type.clone(),

View File

@ -104,7 +104,7 @@ impl Service {
let find_all = repositories::game::models::FindAll {
search: match request.search {
Some(s) => Some(repositories::game::models::FindAllSearch {
kgon_vendor_id: s.kgon_vendor_id.map(|d| d as i64),
parent_id: s.parent_id.map(|d| d as i64),
key_like: s.key_like,
category_like: s.category_like,
platform_like: s.platform_like,

View File

@ -90,7 +90,7 @@ impl Synchronizer {
upsert_games.push(repositories::game::models::UpsertGame {
id: g.id,
kgon_vendor_id: v.id,
parent_id: v.id,
key: g.key.clone(),
names: serde_json::to_string(&g.names).expect("names"),
platform: g.platform.clone(),