From fffcc281ccc4bbc3758aeae64f29a664f39f167b Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Wed, 14 Sep 2022 23:30:22 +0700 Subject: [PATCH] push --- client/supplier.go | 20 +++++++++++++++++++- model/supplier_request.go | 8 ++++++++ subject/warehouse.go | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/client/supplier.go b/client/supplier.go index 8c5a193..c41d843 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -102,7 +102,7 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod } // CreateWarehouseIntoServiceSupplier ... -func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehouseResponse) error { +func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) if err != nil { return err @@ -118,3 +118,21 @@ func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWareh } 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 0a5306a..5a19924 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -30,3 +30,11 @@ type CreateSupplierWarehousePayload struct { 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 2824c33..0941b56 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -21,6 +21,7 @@ var Warehouse = struct { AfterUpdateWarehouse string AfterCreateWarehouse string CreateWarehouseIntoServiceSupplier string + UpdateWarehouseIntoServiceSupplier string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -36,4 +37,5 @@ var Warehouse = struct { Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), + UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), }