refactoring
This commit is contained in:
parent
40e687c5d9
commit
e55adae3dc
12
.vscode/launch.json
vendored
12
.vscode/launch.json
vendored
|
@ -23,9 +23,9 @@
|
||||||
"URL_DATABASE": "postgresql://beteran:qwer5795QWER@192.168.50.205:25432/beteran",
|
"URL_DATABASE": "postgresql://beteran:qwer5795QWER@192.168.50.205:25432/beteran",
|
||||||
"URL_BROKER": "nats://192.168.50.205:4222",
|
"URL_BROKER": "nats://192.168.50.205:4222",
|
||||||
"QUEUE_BROKER": "bet.beteran",
|
"QUEUE_BROKER": "bet.beteran",
|
||||||
"K_URL": "https://dev-mw.kgonapi.com",
|
"K_URL": "https://dev-v1.kgonapi.com/",
|
||||||
"K_USERNAME": "Turbo77",
|
"K_USERNAME": "turbo78",
|
||||||
"K_SECRET": "c23d770b873b2ce95747abc57052beb0",
|
"K_SECRET": "561b6f4d6e4c5f1b8a3473c43c3caa84",
|
||||||
},
|
},
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
|
@ -50,9 +50,9 @@
|
||||||
"URL_DATABASE": "postgresql://beteran:qwer5795QWER@192.168.50.205:25432/beteran",
|
"URL_DATABASE": "postgresql://beteran:qwer5795QWER@192.168.50.205:25432/beteran",
|
||||||
"URL_BROKER": "nats://192.168.50.205:4222",
|
"URL_BROKER": "nats://192.168.50.205:4222",
|
||||||
"QUEUE_BROKER": "bet.beteran",
|
"QUEUE_BROKER": "bet.beteran",
|
||||||
"K_URL": "https://dev-mw.kgonapi.com",
|
"K_URL": "https://dev-v1.kgonapi.com/",
|
||||||
"K_USERNAME": "Turbo77",
|
"K_USERNAME": "turbo78",
|
||||||
"K_SECRET": "c23d770b873b2ce95747abc57052beb0",
|
"K_SECRET": "561b6f4d6e4c5f1b8a3473c43c3caa84",
|
||||||
},
|
},
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}"
|
"cwd": "${workspaceFolder}"
|
||||||
|
|
|
@ -86,7 +86,10 @@ impl Api {
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub async fn play(&self, data: models::PlayRequest) -> Result<models::PlayResponse, Error> {
|
pub async fn get_game_url(
|
||||||
|
&self,
|
||||||
|
data: models::GetGameUrlRequest,
|
||||||
|
) -> Result<models::GetGameUrlResponse, Error> {
|
||||||
let mut params = HashMap::new();
|
let mut params = HashMap::new();
|
||||||
|
|
||||||
params.insert("vendorKey", data.vendor_key);
|
params.insert("vendorKey", data.vendor_key);
|
||||||
|
@ -130,7 +133,7 @@ impl Api {
|
||||||
};
|
};
|
||||||
|
|
||||||
match res.status() {
|
match res.status() {
|
||||||
reqwest::StatusCode::OK => match res.json::<models::_PlayResponse>().await {
|
reqwest::StatusCode::OK => match res.json::<models::_GetGameUrlResponse>().await {
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
if r.code != 0 {
|
if r.code != 0 {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
|
@ -147,12 +150,9 @@ impl Api {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
let balance = match r.balance {
|
let balance = r.balance.unwrap_or(0);
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(models::PlayResponse {
|
Ok(models::GetGameUrlResponse {
|
||||||
user_id,
|
user_id,
|
||||||
url,
|
url,
|
||||||
balance,
|
balance,
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub struct ListGamesResponse {
|
||||||
pub games: Vec<Game>,
|
pub games: Vec<Game>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PlayRequest {
|
pub struct GetGameUrlRequest {
|
||||||
pub vendor_key: String,
|
pub vendor_key: String,
|
||||||
pub game_key: String,
|
pub game_key: String,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
|
@ -41,7 +41,7 @@ pub struct PlayRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct _PlayResponse {
|
pub struct _GetGameUrlResponse {
|
||||||
pub code: i64,
|
pub code: i64,
|
||||||
pub msg: Option<String>,
|
pub msg: Option<String>,
|
||||||
#[serde(rename = "userId")]
|
#[serde(rename = "userId")]
|
||||||
|
@ -51,7 +51,7 @@ pub struct _PlayResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PlayResponse {
|
pub struct GetGameUrlResponse {
|
||||||
pub user_id: String,
|
pub user_id: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub balance: i64,
|
pub balance: i64,
|
||||||
|
|
|
@ -135,10 +135,7 @@ impl Api {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = match r.id {
|
let id = r.id.unwrap_or(0);
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(models::CreateMemberResponse { id })
|
Ok(models::CreateMemberResponse { id })
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,22 +66,10 @@ impl Api {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let balance = match r.balance {
|
let balance = r.balance.unwrap_or(0);
|
||||||
Some(v) => v,
|
let balance_bota = r.balance_bota.unwrap_or(0);
|
||||||
None => 0,
|
let balance_sum = r.balance_sum.unwrap_or(0);
|
||||||
};
|
let companies = r.companies.unwrap_or(0);
|
||||||
let balance_bota = match r.balance_bota {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let balance_sum = match r.balance_sum {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let companies = match r.companies {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(models::GetBalanceForUserResponse {
|
Ok(models::GetBalanceForUserResponse {
|
||||||
balance,
|
balance,
|
||||||
|
@ -139,14 +127,8 @@ impl Api {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let balance = match r.balance {
|
let balance = r.balance.unwrap_or(0);
|
||||||
Some(v) => v,
|
let balance_bota = r.balance_bota.unwrap_or(0);
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let balance_bota = match r.balance_bota {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(models::GetBalanceForPartnerResponse {
|
Ok(models::GetBalanceForPartnerResponse {
|
||||||
balance,
|
balance,
|
||||||
|
@ -214,10 +196,7 @@ impl Api {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let balance = match r.balance {
|
let balance = r.balance.unwrap_or(0);
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(models::CreateDepositResponse { balance })
|
Ok(models::CreateDepositResponse { balance })
|
||||||
}
|
}
|
||||||
|
@ -278,22 +257,10 @@ impl Api {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let balance = match r.balance {
|
let balance = r.balance.unwrap_or(0);
|
||||||
Some(v) => v,
|
let balance_cash = r.balance_cash.unwrap_or(0);
|
||||||
None => 0,
|
let balance_cash_bota = r.balance_cash_bota.unwrap_or(0);
|
||||||
};
|
let amount = r.amount.unwrap_or(0);
|
||||||
let balance_cash = match r.balance_cash {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let balance_cash_bota = match r.balance_cash_bota {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let amount = match r.amount {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(models::CreateWithdrawResponse {
|
Ok(models::CreateWithdrawResponse {
|
||||||
balance,
|
balance,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user