diff --git a/client/segmnet.go b/client/segmnet.go new file mode 100644 index 0000000..bcc7bab --- /dev/null +++ b/client/segmnet.go @@ -0,0 +1,41 @@ +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" +) + +// Segment ... +type Segment struct{} + +// GetSegment ... +func GetSegment() Segment { + return Segment{} +} + +// GetListSegmentInfoByIds ... +func (s Segment) GetListSegmentInfoByIds(p model.GetListSegmentRequest) (*model.ResponseListSegmentInfo, error) { + msg, err := natsio.GetServer().Request(subject.Segment.GetListSegmentInfo, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSegmentInfo `json:"data"` + Error string `json:"error"` + } + + if err := json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + + if r.Error != "" { + return nil, errors.New(r.Error) + } + + return r.Data, nil +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 0cfa72f..d4ca0a4 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -54,9 +54,11 @@ type SupplierFindAllReq struct { Limit int64 `json:"limit"` Segment string `json:"segment"` IDs []string `json:"ids"` + Status string `json:"status"` // active,inactive } type SupplierCountReq struct { Segment string `json:"segment"` IDs []string `json:"ids"` + Status string `json:"status"` // active,inactive }