refactoring
This commit is contained in:
parent
c4d8c03541
commit
cd36f9eada
|
@ -36,7 +36,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
tokio-cron-scheduler = { version = "0" }
|
tokio-cron-scheduler = { version = "0" }
|
||||||
uuid = { version = "0", features = ["serde", "v4", "v5"] }
|
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-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.65-snapshot" }
|
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.66-snapshot" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -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_key;
|
||||||
DROP INDEX idx_api_kgon_games_category;
|
DROP INDEX idx_api_kgon_games_category;
|
||||||
DROP INDEX idx_api_kgon_games_game_type;
|
DROP INDEX idx_api_kgon_games_game_type;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
CREATE TABLE IF NOT EXISTS api_kgon_games (
|
CREATE TABLE IF NOT EXISTS api_kgon_games (
|
||||||
id BIGINT NOT NULL,
|
id BIGINT NOT NULL,
|
||||||
vendor_id BIGINT NOT NULL,
|
kgon_vendor_id BIGINT NOT NULL,
|
||||||
key TEXT NOT NULL,
|
key TEXT NOT NULL,
|
||||||
names TEXT NOT NULL,
|
names TEXT NOT NULL,
|
||||||
platform 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),
|
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
||||||
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
CONSTRAINT fk_api_kgon_games_vendor_id
|
CONSTRAINT fk_api_kgon_games_kgon_vendor_id
|
||||||
FOREIGN KEY(vendor_id)
|
FOREIGN KEY(kgon_vendor_id)
|
||||||
REFERENCES api_kgon_vendors(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_key ON api_kgon_games (key);
|
||||||
CREATE INDEX idx_api_kgon_games_category ON api_kgon_games (category);
|
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);
|
CREATE INDEX idx_api_kgon_games_game_type ON api_kgon_games (game_type);
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub struct Game {
|
||||||
///
|
///
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
///
|
///
|
||||||
pub vendor_id: i64,
|
pub kgon_vendor_id: i64,
|
||||||
///
|
///
|
||||||
pub key: String,
|
pub key: String,
|
||||||
///
|
///
|
||||||
|
@ -34,7 +34,7 @@ pub struct NewGame {
|
||||||
///
|
///
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
///
|
///
|
||||||
pub vendor_id: i64,
|
pub kgon_vendor_id: i64,
|
||||||
///
|
///
|
||||||
pub key: String,
|
pub key: String,
|
||||||
///
|
///
|
||||||
|
@ -74,7 +74,7 @@ pub struct UpsertGame {
|
||||||
///
|
///
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
///
|
///
|
||||||
pub vendor_id: i64,
|
pub kgon_vendor_id: i64,
|
||||||
///
|
///
|
||||||
pub key: String,
|
pub key: String,
|
||||||
///
|
///
|
||||||
|
@ -93,7 +93,7 @@ pub struct UpsertGame {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FindAllSearch {
|
pub struct FindAllSearch {
|
||||||
///
|
///
|
||||||
pub vendor_id: Option<i64>,
|
pub kgon_vendor_id: Option<i64>,
|
||||||
///
|
///
|
||||||
pub key_like: Option<String>,
|
pub key_like: Option<String>,
|
||||||
///
|
///
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl Repository {
|
||||||
.on_conflict(dsl::id)
|
.on_conflict(dsl::id)
|
||||||
.do_update()
|
.do_update()
|
||||||
.set((
|
.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::key.eq(excluded(dsl::key)),
|
||||||
dsl::names.eq(excluded(dsl::names)),
|
dsl::names.eq(excluded(dsl::names)),
|
||||||
dsl::platform.eq(excluded(dsl::platform)),
|
dsl::platform.eq(excluded(dsl::platform)),
|
||||||
|
@ -90,8 +90,8 @@ impl Repository {
|
||||||
let mut q = api_kgon_games::table.into_boxed();
|
let mut q = api_kgon_games::table.into_boxed();
|
||||||
|
|
||||||
if let Some(s) = &find_all.search {
|
if let Some(s) = &find_all.search {
|
||||||
if let Some(sp) = s.vendor_id {
|
if let Some(sp) = s.kgon_vendor_id {
|
||||||
q = q.filter(api_kgon_games::dsl::vendor_id.eq(sp));
|
q = q.filter(api_kgon_games::dsl::kgon_vendor_id.eq(sp));
|
||||||
}
|
}
|
||||||
if let Some(sp) = &s.key_like {
|
if let Some(sp) = &s.key_like {
|
||||||
q = q.filter(api_kgon_games::dsl::key.like(sp));
|
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();
|
let mut q = api_kgon_games::table.into_boxed();
|
||||||
|
|
||||||
if let Some(s) = &find_all.search {
|
if let Some(s) = &find_all.search {
|
||||||
if let Some(sp) = s.vendor_id {
|
if let Some(sp) = s.kgon_vendor_id {
|
||||||
q = q.filter(api_kgon_games::dsl::vendor_id.eq(sp));
|
q = q.filter(api_kgon_games::dsl::kgon_vendor_id.eq(sp));
|
||||||
}
|
}
|
||||||
if let Some(sp) = &s.key_like {
|
if let Some(sp) = &s.key_like {
|
||||||
q = q.filter(api_kgon_games::dsl::key.like(sp));
|
q = q.filter(api_kgon_games::dsl::key.like(sp));
|
||||||
|
@ -148,8 +148,8 @@ impl Repository {
|
||||||
for s in orderbys {
|
for s in orderbys {
|
||||||
match s {
|
match s {
|
||||||
bcr::pagination::Sort::ASC(property) => match property.as_str() {
|
bcr::pagination::Sort::ASC(property) => match property.as_str() {
|
||||||
"vendor_id" => {
|
"kgon_vendor_id" => {
|
||||||
q = q.order_by(api_kgon_games::vendor_id.asc());
|
q = q.order_by(api_kgon_games::kgon_vendor_id.asc());
|
||||||
}
|
}
|
||||||
"key" => {
|
"key" => {
|
||||||
q = q.order_by(api_kgon_games::key.asc());
|
q = q.order_by(api_kgon_games::key.asc());
|
||||||
|
@ -172,8 +172,8 @@ impl Repository {
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
bcr::pagination::Sort::DESC(property) => match property.as_str() {
|
bcr::pagination::Sort::DESC(property) => match property.as_str() {
|
||||||
"vendor_id" => {
|
"kgon_vendor_id" => {
|
||||||
q = q.order_by(api_kgon_games::vendor_id.desc());
|
q = q.order_by(api_kgon_games::kgon_vendor_id.desc());
|
||||||
}
|
}
|
||||||
"key" => {
|
"key" => {
|
||||||
q = q.order_by(api_kgon_games::key.desc());
|
q = q.order_by(api_kgon_games::key.desc());
|
||||||
|
|
|
@ -7,7 +7,7 @@ table! {
|
||||||
///
|
///
|
||||||
id -> BigInt,
|
id -> BigInt,
|
||||||
///
|
///
|
||||||
vendor_id -> BigInt,
|
kgon_vendor_id -> BigInt,
|
||||||
///
|
///
|
||||||
key -> Text,
|
key -> Text,
|
||||||
///
|
///
|
||||||
|
|
|
@ -6,7 +6,7 @@ impl From<&repositories::game::models::Game> for bpr::models::api::game::Game {
|
||||||
bpr::models::api::game::Game {
|
bpr::models::api::game::Game {
|
||||||
id: d.id as u64,
|
id: d.id as u64,
|
||||||
key: d.key.clone(),
|
key: d.key.clone(),
|
||||||
vendor_id: d.vendor_id as u64,
|
kgon_vendor_id: d.kgon_vendor_id as u64,
|
||||||
names: d.names.clone(),
|
names: d.names.clone(),
|
||||||
platform: d.platform.clone(),
|
platform: d.platform.clone(),
|
||||||
game_type: d.game_type.clone(),
|
game_type: d.game_type.clone(),
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl Service {
|
||||||
let find_all = repositories::game::models::FindAll {
|
let find_all = repositories::game::models::FindAll {
|
||||||
search: match request.search {
|
search: match request.search {
|
||||||
Some(s) => Some(repositories::game::models::FindAllSearch {
|
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,
|
key_like: s.key_like,
|
||||||
category_like: s.category_like,
|
category_like: s.category_like,
|
||||||
platform_like: s.platform_like,
|
platform_like: s.platform_like,
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl Synchronizer {
|
||||||
|
|
||||||
upsert_games.push(repositories::game::models::UpsertGame {
|
upsert_games.push(repositories::game::models::UpsertGame {
|
||||||
id: g.id,
|
id: g.id,
|
||||||
vendor_id: v.id,
|
kgon_vendor_id: v.id,
|
||||||
key: g.key.clone(),
|
key: g.key.clone(),
|
||||||
names: serde_json::to_string(&g.names).expect("names"),
|
names: serde_json::to_string(&g.names).expect("names"),
|
||||||
platform: g.platform.clone(),
|
platform: g.platform.clone(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user