Merge branch 'admin-push-notification-supplier' into develop
This commit is contained in:
commit
9d7ebe2ef0
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue