create_member is modified

This commit is contained in:
병준 박 2022-08-14 15:35:17 +00:00
parent 58703c7bb2
commit 39e7a78e76
2 changed files with 39 additions and 2 deletions

View File

@ -31,7 +31,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.57-snapshot" } beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.58-snapshot" }
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.41-snapshot" } beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.42-snapshot" }
[build-dependencies] [build-dependencies]

View File

@ -22,6 +22,7 @@ pub struct Service<'a> {
member_composition: compositions::member::composition::Composition, member_composition: compositions::member::composition::Composition,
member_repository: repositories::member::repository::Repository, member_repository: repositories::member::repository::Repository,
member_session_repository: repositories::member_session::repository::Repository, member_session_repository: repositories::member_session::repository::Repository,
member_bank_account_repository: repositories::member_bank_account::repository::Repository,
argon2_config: argon2::Config<'a>, argon2_config: argon2::Config<'a>,
password_salt: String, password_salt: String,
} }
@ -49,6 +50,8 @@ impl Service<'_> {
member_composition: compositions::member::composition::Composition::new(), member_composition: compositions::member::composition::Composition::new(),
member_repository: repositories::member::repository::Repository::new(), member_repository: repositories::member::repository::Repository::new(),
member_session_repository: repositories::member_session::repository::Repository::new(), member_session_repository: repositories::member_session::repository::Repository::new(),
member_bank_account_repository:
repositories::member_bank_account::repository::Repository::new(),
argon2_config: argon2::Config::default(), argon2_config: argon2::Config::default(),
password_salt, password_salt,
} }
@ -320,6 +323,40 @@ impl Service<'_> {
}) })
})?; })?;
if let Some(a) = request.bank_account {
let bank_id = uuid::Uuid::from_str(a.bank_id.as_str()).map_err(|e| {
bcr::error::rpc::Error::InvalidParams(bcr::error::rpc::InvalidParams {
message: "invalid bank_id param".to_string(),
detail: bcr::error::rpc::InvalidParamsDetail {
location: "request".to_string(),
param: "bank_id".to_string(),
value: a.bank_id.clone(),
error_type: bcr::error::rpc::InvalidParamsType::Required,
message: e.to_string(),
},
})
})?;
let new_member_bank_account =
repositories::member_bank_account::models::NewMemberBankAccount {
member_id: m.id,
bank_id,
name: a.name,
account_number: a.account_number,
memo: None,
};
self
.member_bank_account_repository
.insert(&conn, &new_member_bank_account)
.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 member = self.member_composition.select(&conn, m.id).map_err(|e| { let member = self.member_composition.select(&conn, m.id).map_err(|e| {
bcr::error::rpc::Error::Server(bcr::error::rpc::Server { bcr::error::rpc::Error::Server(bcr::error::rpc::Server {
code: bpr::protobuf::rpc::Error::SERVER_00, code: bpr::protobuf::rpc::Error::SERVER_00,