Merge branch 'build-auth-sms' of git.selly.red:Selly-Modules/natsio into develop

This commit is contained in:
Tue 2022-11-09 14:28:29 +07:00
commit 87d6bba079
3 changed files with 27 additions and 3 deletions

View File

@ -46,11 +46,33 @@ func (s Bank) CheckBankAndBranchByID(p model.CheckBankAndBranchByIDRequest) bool
} }
var r struct { var r struct {
Error string `json:"error"` Data bool `json:"data"`
} }
if err = json.Unmarshal(msg.Data, &r); err != nil { if err = json.Unmarshal(msg.Data, &r); err != nil {
return false return false
} }
return r.Error == "" return r.Data
}
// GetBankAndBranchDetail ...
func (s Bank) GetBankAndBranchDetail(p model.GetBankInfoRequest) (*model.ResponseBankInfo, error) {
msg, err := natsio.GetServer().Request(subject.Bank.GetBankInfoDetail, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseBankInfo `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
} }

View File

@ -8,7 +8,7 @@ type MultiLang struct {
Vi string `json:"vi"` Vi string `json:"vi"`
} }
// BankBranchBrief ... // BranchBrief ...
type BranchBrief struct { type BranchBrief struct {
ID string `json:"_id"` ID string `json:"_id"`
City string `json:"city"` City string `json:"city"`

View File

@ -8,8 +8,10 @@ func getBankValue(val string) string {
var Bank = struct { var Bank = struct {
GetBankInfo string GetBankInfo string
GetBankInfoDetail string
CheckBankAndBranchByID string CheckBankAndBranchByID string
}{ }{
GetBankInfo: getBankValue("get_bank_info"), GetBankInfo: getBankValue("get_bank_info"),
GetBankInfoDetail: getBankValue("get_bank_info_detail"),
CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"), CheckBankAndBranchByID: getBankValue("check_bank_and_branch_by_id"),
} }