Feature/get bank info #23
|
@ -17,7 +17,7 @@ func GetBank() Bank {
|
||||||
return Bank{}
|
return Bank{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Bank) GetBankById(bankID model.BankRequestPayload) (*model.BankBrief, error) {
|
func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) {
|
||||||
msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID))
|
msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/Selly-Modules/natsio"
|
||||||
|
"github.com/Selly-Modules/natsio/model"
|
||||||
|
"github.com/Selly-Modules/natsio/subject"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BankBranch ...
|
||||||
|
type BankBranch struct{}
|
||||||
|
|
||||||
|
// GetBankBranch ...
|
||||||
|
func GetBankBranch() Bank {
|
||||||
|
return Bank{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Bank) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Bank.GetBankBranchById, toBytes(bankBranchID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r struct {
|
||||||
|
Data *model.BankBranchBrief `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
|
||||||
|
}
|
|
@ -126,3 +126,21 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC
|
||||||
}
|
}
|
||||||
return r.Data, nil
|
return r.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateWarehouseIntoServiceSupplier ...
|
||||||
|
func (w Warehouse) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehouseResponse) error {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return errors.New(r.Error)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
// BankBranchBrief ...
|
||||||
|
type BankBranchBrief struct {
|
||||||
|
ID string `json:"_id"`
|
||||||
|
City string `json:"city"`
|
||||||
|
BankCode string `json:"bankCode"`
|
||||||
|
Bank string `json:"bank"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
|
@ -1,6 +0,0 @@
|
||||||
package model
|
|
||||||
|
|
||||||
// BankRequestPayload ...
|
|
||||||
type BankRequestPayload struct {
|
|
||||||
ID string `json:"_id"`
|
|
||||||
}
|
|
|
@ -12,8 +12,6 @@ type BankBrief struct {
|
||||||
Name MultiLang `json:"name"`
|
Name MultiLang `json:"name"`
|
||||||
ShortName string `json:"shortName"`
|
ShortName string `json:"shortName"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
CreatedAt string `json:"createdAt"`
|
|
||||||
UpdatedAt string `json:"updatedAt"`
|
|
||||||
BenBankName string `json:"benBankName"`
|
BenBankName string `json:"benBankName"`
|
||||||
BankCode int `json:"bankCode"`
|
BankCode int `json:"bankCode"`
|
||||||
IsBranchRequired bool `json:"isBranchRequired"`
|
IsBranchRequired bool `json:"isBranchRequired"`
|
||||||
|
|
|
@ -120,3 +120,11 @@ type WarehouseNatsResponse struct {
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateSupplierWarehouseResponse struct {
|
||||||
|
Supplier string `json:"supplier"`
|
||||||
|
Warehouse string `json:"warehouse"`
|
||||||
|
ProvinceCode int `json:"provinceCode"`
|
||||||
|
DistrictCode int `json:"districtCode"`
|
||||||
|
WardCode int `json:"wardCode"`
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ func getBankValue(val string) string {
|
||||||
|
|
||||||
var Bank = struct {
|
var Bank = struct {
|
||||||
GetBankById string
|
GetBankById string
|
||||||
|
GetBankBranchById string
|
||||||
}{
|
}{
|
||||||
GetBankById: getBankValue("get_bank_by_id"),
|
GetBankBranchById: getBankValue("get_bank_by_id"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ var Warehouse = struct {
|
||||||
Count string
|
Count string
|
||||||
AfterUpdateWarehouse string
|
AfterUpdateWarehouse string
|
||||||
AfterCreateWarehouse string
|
AfterCreateWarehouse string
|
||||||
|
CreateWarehouseIntoServiceSupplier string
|
||||||
}{
|
}{
|
||||||
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
|
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
|
||||||
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
|
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
|
||||||
|
@ -34,4 +35,5 @@ var Warehouse = struct {
|
||||||
FindByCondition: getWarehouseValue("find_all_by_condition"),
|
FindByCondition: getWarehouseValue("find_all_by_condition"),
|
||||||
Distinct: getWarehouseValue("distinct"),
|
Distinct: getWarehouseValue("distinct"),
|
||||||
Count: getWarehouseValue("count"),
|
Count: getWarehouseValue("count"),
|
||||||
|
CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue