diff --git a/client/bank.go b/client/bank.go index 5650b2f..86b3d94 100644 --- a/client/bank.go +++ b/client/bank.go @@ -37,3 +37,19 @@ func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { return r.Data, nil } + +func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { + msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) + if err != nil { + return false + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return false + } + return r.Error == "" +} diff --git a/model/bank_branch_request.go b/model/bank_branch_request.go new file mode 100644 index 0000000..6de1216 --- /dev/null +++ b/model/bank_branch_request.go @@ -0,0 +1,6 @@ +package model + +type BankBranchRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} diff --git a/subject/bank.go b/subject/bank.go index a991d5d..9f7f8bb 100644 --- a/subject/bank.go +++ b/subject/bank.go @@ -7,9 +7,11 @@ func getBankValue(val string) string { } var Bank = struct { - GetBankById string - GetBankBranchById string + GetBankById string + GetBankBranchById string + CheckBankAndBranchByID string }{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), + GetBankById: getBankValue("get_bank_by_id"), + GetBankBranchById: getBankValue("get_bank_branch_by_id"), + CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), }