member_game_setting, member_settlement_setting are added
This commit is contained in:
parent
5572d048bc
commit
66a50a1b9e
10
src/main.rs
10
src/main.rs
|
@ -7,8 +7,10 @@ mod member_bank_account;
|
||||||
mod member_bank_deposit;
|
mod member_bank_deposit;
|
||||||
mod member_bank_withdraw;
|
mod member_bank_withdraw;
|
||||||
mod member_class;
|
mod member_class;
|
||||||
|
mod member_game_setting;
|
||||||
mod member_level;
|
mod member_level;
|
||||||
mod member_referrer;
|
mod member_referrer;
|
||||||
|
mod member_settlement_setting;
|
||||||
mod site;
|
mod site;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
|
@ -40,10 +42,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
member_bank_withdraw::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
member_bank_withdraw::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
let member_class_service =
|
let member_class_service =
|
||||||
member_class::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
member_class::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
let member_game_setting_service =
|
||||||
|
member_game_setting::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
let member_level_service =
|
let member_level_service =
|
||||||
member_level::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
member_level::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
let member_referrer_service =
|
let member_referrer_service =
|
||||||
member_referrer::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
member_referrer::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
let member_settlement_setting_service = member_settlement_setting::service::Service::new(
|
||||||
|
connection_broker.clone(),
|
||||||
|
queue_broker.clone(),
|
||||||
|
);
|
||||||
let site_service = site::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
let site_service = site::service::Service::new(connection_broker.clone(), queue_broker.clone());
|
||||||
|
|
||||||
let api_vendor_service =
|
let api_vendor_service =
|
||||||
|
@ -61,8 +69,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
member_bank_deposit_service.subscribe(),
|
member_bank_deposit_service.subscribe(),
|
||||||
member_bank_withdraw_service.subscribe(),
|
member_bank_withdraw_service.subscribe(),
|
||||||
member_class_service.subscribe(),
|
member_class_service.subscribe(),
|
||||||
|
member_game_setting_service.subscribe(),
|
||||||
member_level_service.subscribe(),
|
member_level_service.subscribe(),
|
||||||
member_referrer_service.subscribe(),
|
member_referrer_service.subscribe(),
|
||||||
|
member_settlement_setting_service.subscribe(),
|
||||||
site_service.subscribe(),
|
site_service.subscribe(),
|
||||||
api_vendor_service.subscribe(),
|
api_vendor_service.subscribe(),
|
||||||
api_game_service.subscribe(),
|
api_game_service.subscribe(),
|
||||||
|
|
1
src/member_game_setting/mod.rs
Normal file
1
src/member_game_setting/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod service;
|
594
src/member_game_setting/service.rs
Normal file
594
src/member_game_setting/service.rs
Normal file
|
@ -0,0 +1,594 @@
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("beteran-backend-server-edge::member_game_setting::service::Service")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(connection_broker: nats::asynk::Connection, queue_broker: String) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(
|
||||||
|
self.create_member_game_setting(),
|
||||||
|
self.list_member_game_settings(),
|
||||||
|
self.get_member_game_setting(),
|
||||||
|
self.update_member_game_setting(),
|
||||||
|
self.delete_member_game_setting(),
|
||||||
|
)
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_client_in_header(
|
||||||
|
&self,
|
||||||
|
message: &nats::asynk::Message,
|
||||||
|
) -> Result<bpr::models::core::network::Client, bcr::error::rpc::Error> {
|
||||||
|
match &message.headers {
|
||||||
|
Some(headers) => {
|
||||||
|
let client = match headers.get(bpr::c2se::core::network::HEADER_CLIENT) {
|
||||||
|
Some(c) => {
|
||||||
|
let msg = base64::decode(c).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
bpr::models::core::network::Client::decode(msg.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
|
None => Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid header".to_string(),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn create_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_game_setting::SUBJECT_CREATE_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_game_setting::CreateMemberGameSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_create_member_game_setting_req =
|
||||||
|
bpr::ss::member_game_setting::CreateMemberGameSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(
|
||||||
|
bpr::ss::member_game_setting::create_member_game_setting_request::Request {
|
||||||
|
member_id: req.member_id,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_create_member_game_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_CREATE_MEMBER_GAME_SETTING,
|
||||||
|
ss_create_member_game_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_create_member_game_setting_res =
|
||||||
|
bpr::ss::member_game_setting::CreateMemberGameSettingResponse::decode(
|
||||||
|
ss_create_member_game_setting_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_create_member_game_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_create_member_game_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::CreateMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::c2se::member_game_setting::create_member_game_setting_response::Result {
|
||||||
|
member_game_setting: r.member_game_setting,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::CreateMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_member_game_settings(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_game_setting::SUBJECT_LIST_MEMBER_GAME_SETTINGS,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_game_setting::ListMemberGameSettingsRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_member_game_settings_req = bpr::ss::member_game_setting::ListMemberGameSettingsRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_game_setting::list_member_game_settings_request::Request {
|
||||||
|
pagination: req.pagination,
|
||||||
|
sorts: req.sorts,
|
||||||
|
search: match req.search {
|
||||||
|
Some(s) => Some(bpr::ss::member_game_setting::list_member_game_settings_request::request::Search{
|
||||||
|
member_id: s.member_id,
|
||||||
|
}),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_list_member_game_settings_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_LIST_MEMBER_GAME_SETTINGS,
|
||||||
|
ss_list_member_game_settings_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_member_game_settings_res =
|
||||||
|
bpr::ss::member_game_setting::ListMemberGameSettingsResponse::decode(ss_list_member_game_settings_res_msg.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_list_member_game_settings_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_list_member_game_settings_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::ListMemberGameSettingsResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_game_setting::list_member_game_settings_response::Result {
|
||||||
|
member_game_settings: r.member_game_settings,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::ListMemberGameSettingsResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_game_setting::SUBJECT_GET_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_game_setting::GetMemberGameSettingRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_get_member_game_setting_req = bpr::ss::member_game_setting::GetMemberGameSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_game_setting::get_member_game_setting_request::Request{
|
||||||
|
id: req.id,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_game_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_GET_MEMBER_GAME_SETTING,
|
||||||
|
ss_get_member_game_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_get_member_game_setting_res =
|
||||||
|
bpr::ss::member_game_setting::GetMemberGameSettingResponse::decode(ss_get_member_game_setting_res_msg.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_get_member_game_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_get_member_game_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::GetMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_game_setting::get_member_game_setting_response::Result { member_game_setting: r.member_game_setting }),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::GetMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_game_setting::SUBJECT_UPDATE_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_game_setting::UpdateMemberGameSettingRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_update_member_game_setting_req = bpr::ss::member_game_setting::UpdateMemberGameSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_game_setting::update_member_game_setting_request::Request{
|
||||||
|
id: req.id,
|
||||||
|
can_bet_casino: req.can_bet_casino,
|
||||||
|
can_bet_slot: req.can_bet_slot,
|
||||||
|
can_bet_powerball: req.can_bet_powerball,
|
||||||
|
can_bet_powerladder: req.can_bet_powerladder,
|
||||||
|
can_bet_eos: req.can_bet_eos,
|
||||||
|
can_bet_bogglepowerball: req.can_bet_bogglepowerball,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_update_member_game_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_UPDATE_MEMBER_GAME_SETTING,
|
||||||
|
ss_update_member_game_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_update_member_game_setting_res = bpr::ss::member_game_setting::UpdateMemberGameSettingResponse::decode(
|
||||||
|
ss_update_member_game_setting_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_update_member_game_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_update_member_game_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::UpdateMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_game_setting::update_member_game_setting_response::Result {
|
||||||
|
member_game_setting: r.member_game_setting,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::UpdateMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_member_game_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_game_setting::SUBJECT_DELETE_MEMBER_GAME_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_game_setting::DeleteMemberGameSettingRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_delete_member_game_setting_req = bpr::ss::member_game_setting::DeleteMemberGameSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_game_setting::delete_member_game_setting_request::Request {
|
||||||
|
id: req.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_delete_member_game_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_game_setting::SUBJECT_DELETE_MEMBER_GAME_SETTING,
|
||||||
|
ss_delete_member_game_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_delete_member_game_setting_res = bpr::ss::member_game_setting::DeleteMemberGameSettingResponse::decode(
|
||||||
|
ss_delete_member_game_setting_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_delete_member_game_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_delete_member_game_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::DeleteMemberGameSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_game_setting::delete_member_game_setting_response::Result {}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_game_setting::DeleteMemberGameSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
1
src/member_settlement_setting/mod.rs
Normal file
1
src/member_settlement_setting/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod service;
|
608
src/member_settlement_setting/service.rs
Normal file
608
src/member_settlement_setting/service.rs
Normal file
|
@ -0,0 +1,608 @@
|
||||||
|
use beteran_common_rust as bcr;
|
||||||
|
use beteran_protobuf_rust as bpr;
|
||||||
|
use prost::Message;
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Service {
|
||||||
|
connection_broker: nats::asynk::Connection,
|
||||||
|
queue_broker: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Service {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
f.debug_struct("beteran-backend-server-edge::member_settlement_setting::service::Service")
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
///
|
||||||
|
pub fn new(connection_broker: nats::asynk::Connection, queue_broker: String) -> Service {
|
||||||
|
Service {
|
||||||
|
connection_broker,
|
||||||
|
queue_broker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe(&self) -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
|
||||||
|
futures::try_join!(
|
||||||
|
self.create_member_settlement_setting(),
|
||||||
|
self.list_member_settlement_settings(),
|
||||||
|
self.get_member_settlement_setting(),
|
||||||
|
self.update_member_settlement_setting(),
|
||||||
|
self.delete_member_settlement_setting(),
|
||||||
|
)
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_client_in_header(
|
||||||
|
&self,
|
||||||
|
message: &nats::asynk::Message,
|
||||||
|
) -> Result<bpr::models::core::network::Client, bcr::error::rpc::Error> {
|
||||||
|
match &message.headers {
|
||||||
|
Some(headers) => {
|
||||||
|
let client = match headers.get(bpr::c2se::core::network::HEADER_CLIENT) {
|
||||||
|
Some(c) => {
|
||||||
|
let msg = base64::decode(c).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
bpr::models::core::network::Client::decode(msg.as_slice()).map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: format!("invalid header: {}", e),
|
||||||
|
})
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid client information".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
|
}
|
||||||
|
None => Err(bcr::error::rpc::Error::Parse(bcr::error::rpc::Parse {
|
||||||
|
message: "invalid header".to_string(),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn create_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_settlement_setting::SUBJECT_CREATE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_settlement_setting::CreateMemberSettlementSettingRequest::decode(
|
||||||
|
message.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_create_member_settlement_setting_req =
|
||||||
|
bpr::ss::member_settlement_setting::CreateMemberSettlementSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(
|
||||||
|
bpr::ss::member_settlement_setting::create_member_settlement_setting_request::Request {
|
||||||
|
member_id: req.member_id,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_create_member_settlement_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_CREATE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
ss_create_member_settlement_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_create_member_settlement_setting_res =
|
||||||
|
bpr::ss::member_settlement_setting::CreateMemberSettlementSettingResponse::decode(
|
||||||
|
ss_create_member_settlement_setting_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_create_member_settlement_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_create_member_settlement_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::CreateMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(
|
||||||
|
bpr::c2se::member_settlement_setting::create_member_settlement_setting_response::Result {
|
||||||
|
member_settlement_setting: r.member_settlement_setting,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::CreateMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn list_member_settlement_settings(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_settlement_setting::SUBJECT_LIST_MEMBER_SETTLEMENT_SETTINGS,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_settlement_setting::ListMemberSettlementSettingsRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_member_settlement_settings_req = bpr::ss::member_settlement_setting::ListMemberSettlementSettingsRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_settlement_setting::list_member_settlement_settings_request::Request {
|
||||||
|
pagination: req.pagination,
|
||||||
|
sorts: req.sorts,
|
||||||
|
search: match req.search {
|
||||||
|
Some(s) => Some(bpr::ss::member_settlement_setting::list_member_settlement_settings_request::request::Search{
|
||||||
|
member_id: s.member_id,
|
||||||
|
}),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_list_member_settlement_settings_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_LIST_MEMBER_SETTLEMENT_SETTINGS,
|
||||||
|
ss_list_member_settlement_settings_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_list_member_settlement_settings_res =
|
||||||
|
bpr::ss::member_settlement_setting::ListMemberSettlementSettingsResponse::decode(ss_list_member_settlement_settings_res_msg.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_list_member_settlement_settings_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_list_member_settlement_settings_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::ListMemberSettlementSettingsResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_settlement_setting::list_member_settlement_settings_response::Result {
|
||||||
|
member_settlement_settings: r.member_settlement_settings,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::ListMemberSettlementSettingsResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_settlement_setting::SUBJECT_GET_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_settlement_setting::GetMemberSettlementSettingRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_get_member_settlement_setting_req = bpr::ss::member_settlement_setting::GetMemberSettlementSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_settlement_setting::get_member_settlement_setting_request::Request{
|
||||||
|
id: req.id,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_settlement_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_GET_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
ss_get_member_settlement_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_get_member_settlement_setting_res =
|
||||||
|
bpr::ss::member_settlement_setting::GetMemberSettlementSettingResponse::decode(ss_get_member_settlement_setting_res_msg.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_get_member_settlement_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_get_member_settlement_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::GetMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_settlement_setting::get_member_settlement_setting_response::Result { member_settlement_setting: r.member_settlement_setting }),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::GetMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_settlement_setting::SUBJECT_UPDATE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_settlement_setting::UpdateMemberSettlementSettingRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_update_member_settlement_setting_req = bpr::ss::member_settlement_setting::UpdateMemberSettlementSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_settlement_setting::update_member_settlement_setting_request::Request{
|
||||||
|
id: req.id,
|
||||||
|
can_exchange: req.can_exchange,
|
||||||
|
can_first_charge_comp: req.can_first_charge_comp,
|
||||||
|
can_per_charge_comp: req.can_per_charge_comp,
|
||||||
|
manual_payment_type_for_partner: req.manual_payment_type_for_partner,
|
||||||
|
settlement_type: req.settlement_type,
|
||||||
|
rate_casino: req.rate_casino,
|
||||||
|
rate_casino_loosing: req.rate_casino_loosing,
|
||||||
|
rate_casino_bacara: req.rate_casino_bacara,
|
||||||
|
rate_casino_roulette: req.rate_casino_roulette,
|
||||||
|
rate_casino_dragon_tiger: req.rate_casino_dragon_tiger,
|
||||||
|
rate_slot: req.rate_slot,
|
||||||
|
rate_slot_loosing: req.rate_slot_loosing,
|
||||||
|
rate_powerball_single: req.rate_powerball_single,
|
||||||
|
rate_powerball_combo: req.rate_powerball_combo,
|
||||||
|
rate_powerladder_single: req.rate_powerladder_single,
|
||||||
|
rate_powerladder_combo: req.rate_powerladder_combo,
|
||||||
|
rate_eos_single: req.rate_eos_single,
|
||||||
|
rate_eos_combo: req.rate_eos_combo,
|
||||||
|
rate_bogglepowerball_single: req.rate_bogglepowerball_single,
|
||||||
|
rate_bogglepowerball_combo: req.rate_bogglepowerball_combo,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_update_member_settlement_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_UPDATE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
ss_update_member_settlement_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_update_member_settlement_setting_res = bpr::ss::member_settlement_setting::UpdateMemberSettlementSettingResponse::decode(
|
||||||
|
ss_update_member_settlement_setting_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_update_member_settlement_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_update_member_settlement_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::UpdateMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_settlement_setting::update_member_settlement_setting_response::Result {
|
||||||
|
member_settlement_setting: r.member_settlement_setting,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::UpdateMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_member_settlement_setting(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let s = self
|
||||||
|
.connection_broker
|
||||||
|
.queue_subscribe(
|
||||||
|
bpr::c2se::backend::member_settlement_setting::SUBJECT_DELETE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
self.queue_broker.as_str(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
while let Some(message) = s.next().await {
|
||||||
|
if let Err(e) = async {
|
||||||
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let req = bpr::c2se::member_settlement_setting::DeleteMemberSettlementSettingRequest::decode(message.data.as_slice())
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::InvalidRequest(bcr::error::rpc::InvalidRequest {
|
||||||
|
message: format!("invalid request: {}", e),
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_delete_member_settlement_setting_req = bpr::ss::member_settlement_setting::DeleteMemberSettlementSettingRequest {
|
||||||
|
client: Some(client),
|
||||||
|
request: Some(bpr::ss::member_settlement_setting::delete_member_settlement_setting_request::Request {
|
||||||
|
id: req.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_delete_member_settlement_setting_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_settlement_setting::SUBJECT_DELETE_MEMBER_SETTLEMENT_SETTING,
|
||||||
|
ss_delete_member_settlement_setting_req.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let ss_delete_member_settlement_setting_res = bpr::ss::member_settlement_setting::DeleteMemberSettlementSettingResponse::decode(
|
||||||
|
ss_delete_member_settlement_setting_res_msg.data.as_slice(),
|
||||||
|
)
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(e) = ss_delete_member_settlement_setting_res.error {
|
||||||
|
return Err(bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(r) = ss_delete_member_settlement_setting_res.result {
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::DeleteMemberSettlementSettingResponse {
|
||||||
|
error: None,
|
||||||
|
result: Some(bpr::c2se::member_settlement_setting::delete_member_settlement_setting_response::Result {}),
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
|
||||||
|
code: bpr::protobuf::rpc::Error::SERVER_00,
|
||||||
|
message: format!("server {}", e),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<(), bcr::error::rpc::Error>(())
|
||||||
|
}
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
message
|
||||||
|
.respond(
|
||||||
|
bpr::c2se::member_settlement_setting::DeleteMemberSettlementSettingResponse {
|
||||||
|
error: Some(bpr::protobuf::rpc::Error::from(e)),
|
||||||
|
result: None,
|
||||||
|
}
|
||||||
|
.encode_to_vec(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user