refactor-location #134
|
@ -3,6 +3,7 @@ package client
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/Selly-Modules/natsio"
|
||||
"github.com/Selly-Modules/natsio/model"
|
||||
"github.com/Selly-Modules/natsio/subject"
|
||||
|
@ -38,3 +39,27 @@ func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.Response
|
|||
|
||||
return r.Data, nil
|
||||
}
|
||||
|
||||
// GetListSellerInfoByIDs ...
|
||||
func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r struct {
|
||||
Data *model.ResponseListSellerInfo `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
|
||||
}
|
||||
|
|
|
@ -6,3 +6,8 @@ import "go.mongodb.org/mongo-driver/bson/primitive"
|
|||
type GetSellerByIDRequest struct {
|
||||
SellerID primitive.ObjectID `json:"sellerId"`
|
||||
}
|
||||
|
||||
// GetListSellerByIDsRequest ...
|
||||
type GetListSellerByIDsRequest struct {
|
||||
SellerIDs []primitive.ObjectID `json:"sellerIds"`
|
||||
}
|
||||
|
|
|
@ -6,3 +6,8 @@ type ResponseSellerInfo struct {
|
|||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
// ResponseListSellerInfo ...
|
||||
type ResponseListSellerInfo struct {
|
||||
Sellers []ResponseSellerInfo `json:"sellers"`
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ func getSellerValue(val string) string {
|
|||
|
||||
// Seller ...
|
||||
var Seller = struct {
|
||||
GetSellerInfoByID string
|
||||
GetSellerInfoByID string
|
||||
GetListSellerInfoByIDs string
|
||||
}{
|
||||
GetSellerInfoByID: getSellerValue("get_seller_info_by_id"),
|
||||
GetSellerInfoByID: getSellerValue("get_seller_info_by_id"),
|
||||
GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue