diff --git a/client/warehouse_dao.go b/client/warehouse_dao.go index 56c046f..f2564ed 100644 --- a/client/warehouse_dao.go +++ b/client/warehouse_dao.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "errors" + "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" "git.selly.red/Selly-Modules/natsio/subject" @@ -83,3 +84,21 @@ func (w Warehouse) FindByCondition(p model.FindWithCondition) ([]*model.Warehous } return r.Data, nil } + +// UpdateWarehouseConfig ... +func (w Warehouse) UpdateWarehouseConfig(p model.UpdatePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseConfig, bsonToBytes(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/common_request.go b/model/common_request.go index e3b36da..7cbe1ea 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -49,3 +49,9 @@ type RequestCondition struct { Page int64 `json:"page"` Limit int64 `json:"limit"` } + +type UpdatePayload struct { + Conditions interface{} `json:"conditions"` + Payload interface{} `json:"payload"` + Opts []*options.UpdateOptions `json:"opts"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index 367364b..c02eaec 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -32,6 +32,7 @@ var Warehouse = struct { UpdateORDeliveryStatus string UpdateStatusWarehousePendingInactive string UpdateIsSellyMall string + UpdateWarehouseConfig string }{ SyncWarehouseIntoServiceSupplier: getWarehouseValue("sync_warehouse_into_service_supplier"), CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), @@ -56,4 +57,5 @@ var Warehouse = struct { UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), UpdateStatusWarehousePendingInactive: getWarehouseValue("update_pending_active_product_by_warehouse_ids"), UpdateIsSellyMall: getWarehouseValue("update_is_selly_mall"), + UpdateWarehouseConfig: getWarehouseValue("update_warehouse_config"), }