refactor-location #134

Closed
trunglam wants to merge 270 commits from refactor-location into master
2 changed files with 43 additions and 0 deletions
Showing only changes of commit 9d7ebe2ef0 - Show all commits

41
client/segmnet.go Normal file
View File

@ -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
}

View File

@ -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
}