From 39e7a78e769ac90460d86a6f09c07d0167ca0ce3 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Sun, 14 Aug 2022 15:35:17 +0000 Subject: [PATCH] create_member is modified --- Cargo.toml | 4 ++-- src/services/member/service.rs | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b258e4b..e937594 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio-cron-scheduler = { version = "0" } 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-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.41-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.42-snapshot" } [build-dependencies] diff --git a/src/services/member/service.rs b/src/services/member/service.rs index 8c7867c..467f99e 100644 --- a/src/services/member/service.rs +++ b/src/services/member/service.rs @@ -22,6 +22,7 @@ pub struct Service<'a> { member_composition: compositions::member::composition::Composition, member_repository: repositories::member::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>, password_salt: String, } @@ -49,6 +50,8 @@ impl Service<'_> { member_composition: compositions::member::composition::Composition::new(), member_repository: repositories::member::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(), 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| { bcr::error::rpc::Error::Server(bcr::error::rpc::Server { code: bpr::protobuf::rpc::Error::SERVER_00,