get list seller by ids

This commit is contained in:
phuanbui 2022-09-19 11:48:30 +07:00
parent 40533e1805
commit 89967955ea
4 changed files with 39 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package client
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"github.com/Selly-Modules/natsio" "github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model" "github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject" "github.com/Selly-Modules/natsio/subject"
@ -38,3 +39,27 @@ func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.Response
return r.Data, nil 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
}

View File

@ -6,3 +6,8 @@ import "go.mongodb.org/mongo-driver/bson/primitive"
type GetSellerByIDRequest struct { type GetSellerByIDRequest struct {
SellerID primitive.ObjectID `json:"sellerId"` SellerID primitive.ObjectID `json:"sellerId"`
} }
// GetListSellerByIDsRequest ...
type GetListSellerByIDsRequest struct {
SellerIDs []primitive.ObjectID `json:"sellerIds"`
}

View File

@ -6,3 +6,8 @@ type ResponseSellerInfo struct {
Name string `json:"name"` Name string `json:"name"`
Code string `json:"code"` Code string `json:"code"`
} }
// ResponseListSellerInfo ...
type ResponseListSellerInfo struct {
Sellers []ResponseSellerInfo `json:"sellers"`
}

View File

@ -9,6 +9,8 @@ func getSellerValue(val string) string {
// Seller ... // Seller ...
var Seller = struct { 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"),
} }