From 9d0f9f1f34b2fbe3ae0a656357b4e15506dd2697 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Fri, 19 Aug 2022 10:14:06 +0000 Subject: [PATCH] api is changed --- src/api/game/api.rs | 9 +++++++- src/api/game/models.rs | 2 +- src/api/member_account/api.rs | 36 +++++++++++++++++++++++--------- src/api/member_account/models.rs | 12 +++++------ src/api/vendor/api.rs | 9 +++++++- src/api/vendor/models.rs | 2 +- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/api/game/api.rs b/src/api/game/api.rs index ff8fb7d..5a869c0 100644 --- a/src/api/game/api.rs +++ b/src/api/game/api.rs @@ -66,7 +66,14 @@ impl Api { }); } - Ok(models::ListGamesResponse { games: r.games }) + if let Some(games) = r.games { + Ok(models::ListGamesResponse { games }) + } else { + Err(Error { + code: r.code, + msg: r.msg, + }) + } } Err(e) => Err(Error { code: -1, diff --git a/src/api/game/models.rs b/src/api/game/models.rs index 74a9125..37383b8 100644 --- a/src/api/game/models.rs +++ b/src/api/game/models.rs @@ -21,7 +21,7 @@ pub struct ListGamesRequest { pub struct _ListGamesResponse { pub code: i64, pub msg: Option, - pub games: Vec, + pub games: Option>, } #[derive(Debug)] diff --git a/src/api/member_account/api.rs b/src/api/member_account/api.rs index 92617ea..e4ad946 100644 --- a/src/api/member_account/api.rs +++ b/src/api/member_account/api.rs @@ -66,12 +66,21 @@ impl Api { }); } - Ok(models::GetBalanceForUserResponse { - balance: r.balance, - balance_bota: r.balance_bota, - balance_sum: r.balance_sum, - companies: r.companies, - }) + if let (Some(balance), Some(balance_bota), Some(balance_sum), Some(companies)) = + (r.balance, r.balance_bota, r.balance_sum, r.companies) + { + Ok(models::GetBalanceForUserResponse { + balance, + balance_bota, + balance_sum, + companies, + }) + } else { + Err(Error { + code: r.code, + msg: r.msg, + }) + } } Err(e) => Err(Error { code: -1, @@ -122,10 +131,17 @@ impl Api { }); } - Ok(models::GetBalanceForPartnerResponse { - balance: r.balance, - balance_bota: r.balance_bota, - }) + if let (Some(balance), Some(balance_bota)) = (r.balance, r.balance_bota) { + Ok(models::GetBalanceForPartnerResponse { + balance, + balance_bota, + }) + } else { + Err(Error { + code: r.code, + msg: r.msg, + }) + } } Err(e) => Err(Error { code: -1, diff --git a/src/api/member_account/models.rs b/src/api/member_account/models.rs index ef19d60..8d61513 100644 --- a/src/api/member_account/models.rs +++ b/src/api/member_account/models.rs @@ -8,12 +8,12 @@ pub struct GetBalanceForUserRequest { pub struct _GetBalanceForUserResponse { pub code: i64, pub msg: Option, - pub balance: i64, + pub balance: Option, #[serde(rename = "balanceBota")] - pub balance_bota: i64, + pub balance_bota: Option, #[serde(rename = "balanceSum")] - pub balance_sum: i64, - pub companies: i64, + pub balance_sum: Option, + pub companies: Option, } #[derive(Serialize, Deserialize, Debug)] @@ -32,9 +32,9 @@ pub struct GetBalanceForPartnerRequest {} pub struct _GetBalanceForPartnerResponse { pub code: i64, pub msg: Option, - pub balance: i64, + pub balance: Option, #[serde(rename = "balanceBota")] - pub balance_bota: i64, + pub balance_bota: Option, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/api/vendor/api.rs b/src/api/vendor/api.rs index 3853e27..ec740e2 100644 --- a/src/api/vendor/api.rs +++ b/src/api/vendor/api.rs @@ -60,7 +60,14 @@ impl Api { }); } - Ok(models::ListVendorsResponse { vendors: r.vendors }) + if let Some(vendors) = r.vendors { + Ok(models::ListVendorsResponse { vendors }) + } else { + Err(Error { + code: r.code, + msg: r.msg, + }) + } } Err(e) => Err(Error { code: -1, diff --git a/src/api/vendor/models.rs b/src/api/vendor/models.rs index bc918eb..3aaa8c4 100644 --- a/src/api/vendor/models.rs +++ b/src/api/vendor/models.rs @@ -20,7 +20,7 @@ pub struct ListVendorsRequest {} pub struct _ListVendorsResponse { pub code: i64, pub msg: Option, - pub vendors: Vec, + pub vendors: Option>, } #[derive(Debug)]