refactoring

This commit is contained in:
병준 박 2022-08-29 04:01:16 +00:00
parent c4d8c03541
commit cd36f9eada
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.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]

View File

@ -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;

View File

@ -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);

View File

@ -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<i64>,
pub kgon_vendor_id: Option<i64>,
///
pub key_like: Option<String>,
///

View File

@ -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());

View File

@ -7,7 +7,7 @@ table! {
///
id -> BigInt,
///
vendor_id -> BigInt,
kgon_vendor_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(),
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(),

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 {
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,

View File

@ -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(),