From 2e069b94e78274fe9c8f3e40254d33823b2d28f3 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 1 Mar 2023 14:40:34 +0700 Subject: [PATCH] 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"), }