refactoring
This commit is contained in:
parent
c87e49817b
commit
182cdc736f
10
Cargo.toml
10
Cargo.toml
|
@ -11,15 +11,15 @@ path = "./src/main.rs"
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
base64 = { version = "0" }
|
||||||
futures = { version = "0", default-features = false, features = [
|
futures = { version = "0", default-features = false, features = [
|
||||||
"async-await",
|
"async-await",
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
|
||||||
prost = { version = "0" }
|
|
||||||
nats = { version = "0" }
|
nats = { version = "0" }
|
||||||
base64 = { version = "0" }
|
prost = { version = "0" }
|
||||||
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
||||||
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.74-snapshot" }
|
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.77-snapshot" }
|
||||||
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.58-snapshot" }
|
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.62-snapshot" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
9
resources/public.pem
Normal file
9
resources/public.pem
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw/GvSFLy8K5uT79REy5l
|
||||||
|
JtIS+Y9uAP1SJEyLvAqWfdPh9YO5QCnYPp1uCqL3xWozkhrQWUbaYkO+65vjmYcG
|
||||||
|
BMlzO+7KvZcHh4wr8ybA03M6Yy6JSbnXRQvVm2Bvp2Z1B0dkT11CtZxiaNywYFvM
|
||||||
|
hh5+zEbsrbFkzN5zI+hNpyg4uaaQY5Oy2jGW3zuOIy/i0qzs3pCHWDAk0d5hpGvf
|
||||||
|
lUIj7BOQtl7CcFoB8tMp6F2fi8t9m/Qa0yvQz8CNf7pdDqprUlm509wKzB4HgX8a
|
||||||
|
G5SMwMlfuQjvT3jQNLRnHJFDghdZuCaop8IKf4PVGjuLo0SEebYzVEYfzLQrHemo
|
||||||
|
RwIDAQAB
|
||||||
|
-----END PUBLIC KEY-----
|
|
@ -70,6 +70,57 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_member_session_with_renewal(
|
||||||
|
&self,
|
||||||
|
client: &bpr::models::core::network::Client,
|
||||||
|
) -> Result<Option<bpr::models::member_session::MemberSession>, bcr::error::rpc::Error> {
|
||||||
|
let ss_get_member_session_req = bpr::ss::member_session::GetMemberSessionWithRenewalRequest {
|
||||||
|
client: Some(client.clone()),
|
||||||
|
request: Some(bpr::ss::member_session::get_member_session_with_renewal_request::Request {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_session_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_session::SUBJECT_GET_MEMBER_SESSION_WITH_RENEWAL,
|
||||||
|
ss_get_member_session_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_session_res =
|
||||||
|
bpr::ss::member_session::GetMemberSessionWithRenewalResponse::decode(
|
||||||
|
ss_get_member_session_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_session_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_session_res.result {
|
||||||
|
return Ok(r.member_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_member(&self) -> Result<(), Box<dyn std::error::Error>> {
|
async fn create_member(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let s = self
|
let s = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
|
@ -439,6 +490,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req =
|
let req =
|
||||||
bpr::c2se::member::UpdateMemberRequest::decode(message.data.as_slice()).map_err(|e| {
|
bpr::c2se::member::UpdateMemberRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
|
@ -507,7 +568,7 @@ impl Service {
|
||||||
let ss_update_member_req = bpr::ss::member::UpdateMemberRequest {
|
let ss_update_member_req = bpr::ss::member::UpdateMemberRequest {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
request: Some(bpr::ss::member::update_member_request::Request {
|
request: Some(bpr::ss::member::update_member_request::Request {
|
||||||
id: req.id,
|
id: member_session.member_id.clone(),
|
||||||
site_id: req.site_id,
|
site_id: req.site_id,
|
||||||
member_level_id: req.member_level_id,
|
member_level_id: req.member_level_id,
|
||||||
mobile_phone_number: req.mobile_phone_number,
|
mobile_phone_number: req.mobile_phone_number,
|
||||||
|
@ -602,6 +663,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req =
|
let req =
|
||||||
bpr::c2se::member::UpdateMemberForPasswordRequest::decode(message.data.as_slice())
|
bpr::c2se::member::UpdateMemberForPasswordRequest::decode(message.data.as_slice())
|
||||||
|
@ -615,7 +686,7 @@ impl Service {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
request: Some(
|
request: Some(
|
||||||
bpr::ss::member::update_member_for_password_request::Request {
|
bpr::ss::member::update_member_for_password_request::Request {
|
||||||
id: req.id,
|
id: member_session.member_id.clone(),
|
||||||
password: req.password,
|
password: req.password,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -705,6 +776,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req =
|
let req =
|
||||||
bpr::c2se::member::DeleteMemberRequest::decode(message.data.as_slice()).map_err(|e| {
|
bpr::c2se::member::DeleteMemberRequest::decode(message.data.as_slice()).map_err(|e| {
|
||||||
|
@ -715,7 +796,9 @@ impl Service {
|
||||||
|
|
||||||
let ss_delete_member_req = bpr::ss::member::DeleteMemberRequest {
|
let ss_delete_member_req = bpr::ss::member::DeleteMemberRequest {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
request: Some(bpr::ss::member::delete_member_request::Request { id: req.id }),
|
request: Some(bpr::ss::member::delete_member_request::Request {
|
||||||
|
id: member_session.member_id.clone(),
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ss_delete_member_res_msg = self
|
let ss_delete_member_res_msg = self
|
||||||
|
|
|
@ -68,6 +68,57 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_member_session_with_renewal(
|
||||||
|
&self,
|
||||||
|
client: &bpr::models::core::network::Client,
|
||||||
|
) -> Result<Option<bpr::models::member_session::MemberSession>, bcr::error::rpc::Error> {
|
||||||
|
let ss_get_member_session_req = bpr::ss::member_session::GetMemberSessionWithRenewalRequest {
|
||||||
|
client: Some(client.clone()),
|
||||||
|
request: Some(bpr::ss::member_session::get_member_session_with_renewal_request::Request {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_session_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_session::SUBJECT_GET_MEMBER_SESSION_WITH_RENEWAL,
|
||||||
|
ss_get_member_session_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_session_res =
|
||||||
|
bpr::ss::member_session::GetMemberSessionWithRenewalResponse::decode(
|
||||||
|
ss_get_member_session_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_session_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_session_res.result {
|
||||||
|
return Ok(r.member_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_member_bank_account(&self) -> Result<(), Box<dyn std::error::Error>> {
|
async fn create_member_bank_account(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let s = self
|
let s = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
|
|
|
@ -69,6 +69,57 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_member_session_with_renewal(
|
||||||
|
&self,
|
||||||
|
client: &bpr::models::core::network::Client,
|
||||||
|
) -> Result<Option<bpr::models::member_session::MemberSession>, bcr::error::rpc::Error> {
|
||||||
|
let ss_get_member_session_req = bpr::ss::member_session::GetMemberSessionWithRenewalRequest {
|
||||||
|
client: Some(client.clone()),
|
||||||
|
request: Some(bpr::ss::member_session::get_member_session_with_renewal_request::Request {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_session_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_session::SUBJECT_GET_MEMBER_SESSION_WITH_RENEWAL,
|
||||||
|
ss_get_member_session_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_session_res =
|
||||||
|
bpr::ss::member_session::GetMemberSessionWithRenewalResponse::decode(
|
||||||
|
ss_get_member_session_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_session_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_session_res.result {
|
||||||
|
return Ok(r.member_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_member_bank_deposit(&self) -> Result<(), Box<dyn std::error::Error>> {
|
async fn create_member_bank_deposit(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let s = self
|
let s = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
|
@ -82,6 +133,17 @@ impl Service {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_deposit::CreateMemberBankDepositRequest::decode(
|
let req = bpr::c2se::member_bank_deposit::CreateMemberBankDepositRequest::decode(
|
||||||
message.data.as_slice(),
|
message.data.as_slice(),
|
||||||
)
|
)
|
||||||
|
@ -96,7 +158,7 @@ impl Service {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
request: Some(
|
request: Some(
|
||||||
bpr::ss::member_bank_deposit::create_member_bank_deposit_request::Request {
|
bpr::ss::member_bank_deposit::create_member_bank_deposit_request::Request {
|
||||||
member_id: "".to_string(),
|
member_id: member_session.member_id.clone(),
|
||||||
name: req.name,
|
name: req.name,
|
||||||
amount: req.amount,
|
amount: req.amount,
|
||||||
memo: req.memo,
|
memo: req.memo,
|
||||||
|
@ -193,6 +255,17 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_deposit::ListMemberBankDepositsRequest::decode(message.data.as_slice())
|
let req = bpr::c2se::member_bank_deposit::ListMemberBankDepositsRequest::decode(message.data.as_slice())
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -206,18 +279,17 @@ impl Service {
|
||||||
request: Some(bpr::ss::member_bank_deposit::list_member_bank_deposits_request::Request {
|
request: Some(bpr::ss::member_bank_deposit::list_member_bank_deposits_request::Request {
|
||||||
pagination: req.pagination,
|
pagination: req.pagination,
|
||||||
sorts: req.sorts,
|
sorts: req.sorts,
|
||||||
search: match req.search {
|
search: match req.search {
|
||||||
Some(s) => Some(bpr::ss::member_bank_deposit::list_member_bank_deposits_request::request::Search {
|
Some(s) => Some(bpr::ss::member_bank_deposit::list_member_bank_deposits_request::request::Search {
|
||||||
member_id: s.member_id,
|
member_id: Some(member_session.member_id.clone()),
|
||||||
name_like: s.name_like,
|
name_like: s.name_like,
|
||||||
amount: s.amount,
|
amount: s.amount,
|
||||||
state: s.state,
|
state: s.state,
|
||||||
memo_like: s.memo_like,
|
memo_like: s.memo_like,
|
||||||
}),
|
}),
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let ss_list_member_bank_deposits_res_msg = self
|
let ss_list_member_bank_deposits_res_msg = self
|
||||||
|
@ -305,6 +377,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_deposit::GetMemberBankDepositRequest::decode(
|
let req = bpr::c2se::member_bank_deposit::GetMemberBankDepositRequest::decode(
|
||||||
message.data.as_slice(),
|
message.data.as_slice(),
|
||||||
|
@ -412,6 +494,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_deposit::UpdateMemberBankDepositRequest::decode(
|
let req = bpr::c2se::member_bank_deposit::UpdateMemberBankDepositRequest::decode(
|
||||||
message.data.as_slice(),
|
message.data.as_slice(),
|
||||||
|
@ -524,7 +616,17 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_deposit::DeleteMemberBankDepositRequest::decode(
|
let req = bpr::c2se::member_bank_deposit::DeleteMemberBankDepositRequest::decode(
|
||||||
message.data.as_slice(),
|
message.data.as_slice(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -69,6 +69,57 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_member_session_with_renewal(
|
||||||
|
&self,
|
||||||
|
client: &bpr::models::core::network::Client,
|
||||||
|
) -> Result<Option<bpr::models::member_session::MemberSession>, bcr::error::rpc::Error> {
|
||||||
|
let ss_get_member_session_req = bpr::ss::member_session::GetMemberSessionWithRenewalRequest {
|
||||||
|
client: Some(client.clone()),
|
||||||
|
request: Some(bpr::ss::member_session::get_member_session_with_renewal_request::Request {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_session_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_session::SUBJECT_GET_MEMBER_SESSION_WITH_RENEWAL,
|
||||||
|
ss_get_member_session_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_session_res =
|
||||||
|
bpr::ss::member_session::GetMemberSessionWithRenewalResponse::decode(
|
||||||
|
ss_get_member_session_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_session_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_session_res.result {
|
||||||
|
return Ok(r.member_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_member_bank_withdraw(&self) -> Result<(), Box<dyn std::error::Error>> {
|
async fn create_member_bank_withdraw(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let s = self
|
let s = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
|
@ -81,6 +132,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_withdraw::CreateMemberBankWithdrawRequest::decode(
|
let req = bpr::c2se::member_bank_withdraw::CreateMemberBankWithdrawRequest::decode(
|
||||||
message.data.as_slice(),
|
message.data.as_slice(),
|
||||||
|
@ -96,7 +157,7 @@ impl Service {
|
||||||
client: Some(client),
|
client: Some(client),
|
||||||
request: Some(
|
request: Some(
|
||||||
bpr::ss::member_bank_withdraw::create_member_bank_withdraw_request::Request {
|
bpr::ss::member_bank_withdraw::create_member_bank_withdraw_request::Request {
|
||||||
member_id: "".to_string(),
|
member_id: member_session.member_id.clone(),
|
||||||
bank_name: req.bank_name,
|
bank_name: req.bank_name,
|
||||||
account_number: req.account_number,
|
account_number: req.account_number,
|
||||||
amount: req.amount,
|
amount: req.amount,
|
||||||
|
@ -196,6 +257,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_withdraw::ListMemberBankWithdrawsRequest::decode(message.data.as_slice())
|
let req = bpr::c2se::member_bank_withdraw::ListMemberBankWithdrawsRequest::decode(message.data.as_slice())
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -209,18 +280,18 @@ impl Service {
|
||||||
request: Some(bpr::ss::member_bank_withdraw::list_member_bank_withdraws_request::Request{
|
request: Some(bpr::ss::member_bank_withdraw::list_member_bank_withdraws_request::Request{
|
||||||
pagination: req.pagination,
|
pagination: req.pagination,
|
||||||
sorts: req.sorts,
|
sorts: req.sorts,
|
||||||
search: match req.search {
|
search: match req.search {
|
||||||
Some(s) => Some(bpr::ss::member_bank_withdraw::list_member_bank_withdraws_request::request::Search {
|
Some(s) => Some(bpr::ss::member_bank_withdraw::list_member_bank_withdraws_request::request::Search {
|
||||||
name_like: s.name_like,
|
name_like: s.name_like,
|
||||||
member_id: s.member_id,
|
member_id: Some(member_session.member_id.clone()),
|
||||||
bank_name_like: s.bank_name_like,
|
bank_name_like: s.bank_name_like,
|
||||||
account_number_like: s.account_number_like,
|
account_number_like: s.account_number_like,
|
||||||
amount: s.amount,
|
amount: s.amount,
|
||||||
state: s.state,
|
state: s.state,
|
||||||
memo_like: s.memo_like,
|
memo_like: s.memo_like,
|
||||||
}),
|
}),
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -310,6 +381,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_withdraw::GetMemberBankWithdrawRequest::decode(message.data.as_slice())
|
let req = bpr::c2se::member_bank_withdraw::GetMemberBankWithdrawRequest::decode(message.data.as_slice())
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -408,6 +489,16 @@ impl Service {
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_withdraw::UpdateMemberBankWithdrawRequest::decode(message.data.as_slice())
|
let req = bpr::c2se::member_bank_withdraw::UpdateMemberBankWithdrawRequest::decode(message.data.as_slice())
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -515,6 +606,16 @@ password: req.password,
|
||||||
while let Some(message) = s.next().await {
|
while let Some(message) = s.next().await {
|
||||||
if let Err(e) = async {
|
if let Err(e) = async {
|
||||||
let client = self.get_client_in_header(&message)?;
|
let client = self.get_client_in_header(&message)?;
|
||||||
|
let member_session = match self.get_member_session_with_renewal(&client).await? {
|
||||||
|
Some(ms) => ms,
|
||||||
|
None => {
|
||||||
|
return Err(bcr::error::rpc::Error::InvalidRequest(
|
||||||
|
bcr::error::rpc::InvalidRequest {
|
||||||
|
message: "Unauthorized".to_string(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let req = bpr::c2se::member_bank_withdraw::DeleteMemberBankWithdrawRequest::decode(message.data.as_slice())
|
let req = bpr::c2se::member_bank_withdraw::DeleteMemberBankWithdrawRequest::decode(message.data.as_slice())
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
|
|
@ -62,6 +62,57 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_member_session_with_renewal(
|
||||||
|
&self,
|
||||||
|
client: &bpr::models::core::network::Client,
|
||||||
|
) -> Result<Option<bpr::models::member_session::MemberSession>, bcr::error::rpc::Error> {
|
||||||
|
let ss_get_member_session_req = bpr::ss::member_session::GetMemberSessionWithRenewalRequest {
|
||||||
|
client: Some(client.clone()),
|
||||||
|
request: Some(bpr::ss::member_session::get_member_session_with_renewal_request::Request {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ss_get_member_session_res_msg = self
|
||||||
|
.connection_broker
|
||||||
|
.request(
|
||||||
|
bpr::ss::member_session::SUBJECT_GET_MEMBER_SESSION_WITH_RENEWAL,
|
||||||
|
ss_get_member_session_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_session_res =
|
||||||
|
bpr::ss::member_session::GetMemberSessionWithRenewalResponse::decode(
|
||||||
|
ss_get_member_session_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_session_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_session_res.result {
|
||||||
|
return Ok(r.member_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_member_referrer_by_code(&self) -> Result<(), Box<dyn std::error::Error>> {
|
async fn get_member_referrer_by_code(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let s = self
|
let s = self
|
||||||
.connection_broker
|
.connection_broker
|
||||||
|
|
Loading…
Reference in New Issue
Block a user