Feature/seller by #38

Merged
milano15662 merged 16 commits from feature/seller-by-id into master 2022-10-03 03:48:13 +00:00
4 changed files with 39 additions and 2 deletions
Showing only changes of commit c043a03861 - Show all commits

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"),
} }