From b3bde5cd09603c8e21e47824dbf87da14fd67eb0 Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 6 Oct 2023 16:39:40 +0700 Subject: [PATCH 1/5] update communication model --- model/communication_request.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/communication_request.go b/model/communication_request.go index eb64ef2..23b1b50 100644 --- a/model/communication_request.go +++ b/model/communication_request.go @@ -5,6 +5,9 @@ type CommunicationRequestHttp struct { ResponseImmediately bool `json:"responseImmediately"` Authentication string `json:"authentication"` Payload HttpRequest `json:"payload"` + + // collection to store log data, will be prepended with log-, default it stored in logs collections + LogTarget string `json:"logTarget"` } // HttpRequest ... -- 2.34.1 From 28178e0c31a477403054968c135919fbc3f45b06 Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 10 Oct 2023 16:11:19 +0700 Subject: [PATCH 2/5] add func update warehouse config --- client/warehouse_dao.go | 19 +++++++++++++++++++ model/common_request.go | 6 ++++++ subject/warehouse.go | 2 ++ 3 files changed, 27 insertions(+) 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 447ae57..a36f30c 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -43,3 +43,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 9131f07..47a8be4 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -30,6 +30,7 @@ var Warehouse = struct { UpdateORDeliveryStatus string UpdateStatusWarehousePendingInactive string UpdateIsSellyMall string + UpdateWarehouseConfig string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -52,4 +53,5 @@ var Warehouse = struct { UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), UpdateStatusWarehousePendingInactive: getWarehouseValue("update_status_warehouse_pending_inactive"), UpdateIsSellyMall: getWarehouseValue("update_is_selly_mall"), + UpdateWarehouseConfig: getWarehouseValue("update_warehouse_config"), } -- 2.34.1 From e84157281b692d7556634a73ac35cfe232364413 Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 10 Oct 2023 16:33:58 +0700 Subject: [PATCH 3/5] add func bulk write warehouse config --- client/warehouse_dao.go | 18 ++++++++++++++++++ subject/warehouse.go | 2 ++ 2 files changed, 20 insertions(+) diff --git a/client/warehouse_dao.go b/client/warehouse_dao.go index f2564ed..80ba7ff 100644 --- a/client/warehouse_dao.go +++ b/client/warehouse_dao.go @@ -102,3 +102,21 @@ func (w Warehouse) UpdateWarehouseConfig(p model.UpdatePayload) error { } return nil } + +// BulkWriteWarehouseConfig ... +func (w Warehouse) BulkWriteWarehouseConfig(p model.UpdatePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.BulkWriteWarehouseConfig, 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/subject/warehouse.go b/subject/warehouse.go index 47a8be4..0d9a218 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -31,6 +31,7 @@ var Warehouse = struct { UpdateStatusWarehousePendingInactive string UpdateIsSellyMall string UpdateWarehouseConfig string + BulkWriteWarehouseConfig string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -54,4 +55,5 @@ var Warehouse = struct { UpdateStatusWarehousePendingInactive: getWarehouseValue("update_status_warehouse_pending_inactive"), UpdateIsSellyMall: getWarehouseValue("update_is_selly_mall"), UpdateWarehouseConfig: getWarehouseValue("update_warehouse_config"), + BulkWriteWarehouseConfig: getWarehouseValue("bulk_write_warehouse_config"), } -- 2.34.1 From 7302b78f25534382b996f2bcfc0447b814446938 Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 12 Oct 2023 09:14:53 +0700 Subject: [PATCH 4/5] add subject webhook product update --- subject/product.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/product.go b/subject/product.go index 2acfadc..39c5a2b 100644 --- a/subject/product.go +++ b/subject/product.go @@ -12,9 +12,11 @@ var Product = struct { CreateRequestStep string ProcessApplyRequest string RequestChangeStatus string + WebhookStockUpdate string }{ ApplyRequest: getProductValue("apply_request"), CreateRequestStep: getProductValue("create_request_step"), ProcessApplyRequest: getProductValue("process_apply_request"), RequestChangeStatus: getProductValue("request_change_status"), + WebhookStockUpdate: getProductValue("webhook_stock_update"), } -- 2.34.1 From 430e07b7d0d633d8fa19aa30feed78bec587d6d7 Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 12 Oct 2023 15:43:49 +0700 Subject: [PATCH 5/5] add webhook model --- model/common_request.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/model/common_request.go b/model/common_request.go index a36f30c..9a12285 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -49,3 +49,8 @@ type UpdatePayload struct { Payload interface{} `json:"payload"` Opts []*options.UpdateOptions `json:"opts"` } + +type WebhookPayloadV2 struct { + Path string `json:"path"` // request URL path from external + Data string `json:"data"` // request body +} -- 2.34.1