diff --git a/client/supplier.go b/client/supplier.go index 8de78fb..1ed20d0 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -79,3 +79,60 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl return r.Data, nil } + +func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierAll `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 +} + +// CreateWarehouseIntoServiceSupplier ... +func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) 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 +} + +// UpdateWarehouseIntoServiceSupplier ... +func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, 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 +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 04d15d5..5a19924 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -22,3 +22,19 @@ type SupplierRequestPayload struct { PIC string ContractStatus string } + +type CreateSupplierWarehousePayload struct { + Supplier string `json:"supplier"` + Warehouse string `json:"warehouse"` + ProvinceCode int `json:"provinceCode"` + DistrictCode int `json:"districtCode"` + WardCode int `json:"wardCode"` +} + +type UpdateSupplierWarehousePayload struct { + Supplier string `json:"supplier"` + Warehouse string `json:"warehouse"` + ProvinceCode int `json:"provinceCode"` + DistrictCode int `json:"districtCode"` + WardCode int `json:"wardCode"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index 378e1a8..3722edd 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -7,6 +7,8 @@ func getWarehouseValue(val string) string { } var Warehouse = struct { + CreateWarehouseIntoServiceSupplier string + UpdateWarehouseIntoServiceSupplier string CreateOutboundRequest string UpdateOutboundRequestLogistic string CancelOutboundRequest string @@ -23,6 +25,8 @@ var Warehouse = struct { UpdateIsClosedSupplier string GetWarehouses string }{ + CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), + UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), CreateOutboundRequest: getWarehouseValue("create_outbound_request"),