From 79ad5c401c5e1f30c043bcd8bac9352bf06a40cf Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Tue, 28 Feb 2023 15:06:06 +0700 Subject: [PATCH 1/4] subject-subscriber-topic --- js/consumer/selly.go | 2 ++ js/subject/selly.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/js/consumer/selly.go b/js/consumer/selly.go index 975cb5b..103d030 100644 --- a/js/consumer/selly.go +++ b/js/consumer/selly.go @@ -5,8 +5,10 @@ var Selly = struct { PushNotification string UpdateSellerAffiliateStatistic string CheckAnDInsertCashflowBySeller string + SubscriberTopic string }{ PushNotification: "PULL_PUSH_NOTIFICATION", UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", + SubscriberTopic: "PULL_SUBSCRIBER_TOPIC", } diff --git a/js/subject/selly.go b/js/subject/selly.go index 2f665bb..668f249 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -14,8 +14,10 @@ var Selly = struct { PushNotification string UpdateSellerAffiliateStatistic string CheckAnDInsertCashflowBySeller string + SubscriberTopic string }{ PushNotification: getSellyValue("push_notifications"), UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), + SubscriberTopic: getSellyValue("subscriber_topic"), } From 0401a57930b124c64c6779f6e5d9a6d2c362b65a Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Tue, 28 Feb 2023 15:14:49 +0700 Subject: [PATCH 2/4] add model subject subscriber topic --- js/model/selly.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/model/selly.go b/js/model/selly.go index 68d3342..8f5e19c 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -63,3 +63,11 @@ type CashFlowOptions struct { CampaignID string `json:"campaignId,omitempty"` CampaignName string `json:"campaignName,omitempty"` } + +// SubscriberNotificationTopic ... +type SubscriberNotificationTopic struct { + User string `json:"user"` + Topic string `json:"topic"` + DeviceId string `json:"deviceId"` + FCMToken string `json:"fcmToken"` +} From aee7b01b40e3f27cc1a7ac9d29aa948969a321a5 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 1 Mar 2023 10:42:54 +0700 Subject: [PATCH 3/4] notify change price product --- client/product.go | 17 +++++++++++++++++ model/product_request.go | 5 +++++ subject/product.go | 2 ++ 3 files changed, 24 insertions(+) diff --git a/client/product.go b/client/product.go index a581b9d..3dc259d 100644 --- a/client/product.go +++ b/client/product.go @@ -50,3 +50,20 @@ func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error { } return nil } + +func (c Product) RequestChangeStatus(p model.ProductRequestChangeStatus) error { + msg, err := natsio.GetServer().Request(subject.Product.RequestChangeStatus, 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/product_request.go b/model/product_request.go index 1adbec5..d2dcb91 100644 --- a/model/product_request.go +++ b/model/product_request.go @@ -3,3 +3,8 @@ package model type ProductApplyRequestPayload struct { RequestID string `json:"requestId"` } + +type ProductRequestChangeStatus struct { + RequestID string `json:"requestId"` + Status string `json:"status"` +} diff --git a/subject/product.go b/subject/product.go index 348aca9..5ca822e 100644 --- a/subject/product.go +++ b/subject/product.go @@ -10,7 +10,9 @@ func getProductValue(val string) string { var Product = struct { ApplyRequest string ProcessApplyRequest string + RequestChangeStatus string }{ ApplyRequest: getProductValue("apply_request"), ProcessApplyRequest: getProductValue("process_apply_request"), + RequestChangeStatus: getProductValue("request_change_status"), } From 2e069b94e78274fe9c8f3e40254d33823b2d28f3 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 1 Mar 2023 14:40:34 +0700 Subject: [PATCH 4/4] product request multi step --- client/product.go | 17 +++++++++++++++++ model/product_request.go | 4 ++++ subject/product.go | 2 ++ 3 files changed, 23 insertions(+) diff --git a/client/product.go b/client/product.go index a581b9d..febc8d1 100644 --- a/client/product.go +++ b/client/product.go @@ -34,6 +34,23 @@ func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error { return nil } +func (c Product) CreateRequestSteps(p model.ProductCreateStepsPayload) error { + msg, err := natsio.GetServer().Request(subject.Product.CreateRequestStep, 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 +} + func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error { msg, err := natsio.GetServer().Request(subject.Product.ProcessApplyRequest, toBytes(p)) if err != nil { diff --git a/model/product_request.go b/model/product_request.go index 1adbec5..cf82b45 100644 --- a/model/product_request.go +++ b/model/product_request.go @@ -3,3 +3,7 @@ package model type ProductApplyRequestPayload struct { RequestID string `json:"requestId"` } + +type ProductCreateStepsPayload struct { + RequestID string `json:"requestId"` +} diff --git a/subject/product.go b/subject/product.go index 348aca9..7a6035f 100644 --- a/subject/product.go +++ b/subject/product.go @@ -9,8 +9,10 @@ func getProductValue(val string) string { var Product = struct { ApplyRequest string + CreateRequestStep string ProcessApplyRequest string }{ ApplyRequest: getProductValue("apply_request"), + CreateRequestStep: getProductValue("create_request_step"), ProcessApplyRequest: getProductValue("process_apply_request"), }