Fix conflict

This commit is contained in:
Nguyen Minh 2022-09-15 17:04:26 +07:00
commit 139dc6a865
5 changed files with 72 additions and 0 deletions

40
client/seller.go Normal file
View File

@ -0,0 +1,40 @@
package client
import (
"encoding/json"
"errors"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/model"
"github.com/Selly-Modules/natsio/subject"
)
// Seller ...
type Seller struct{}
// GetSeller ...
func GetSeller() Seller {
return Seller{}
}
// GetSellerInfoByID ...
func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.ResponseSellerInfo, error) {
msg, err := natsio.GetServer().Request(subject.Seller.GetSellerInfoByID, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseSellerInfo `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
}

8
model/seller_request.go Normal file
View File

@ -0,0 +1,8 @@
package model
import "go.mongodb.org/mongo-driver/bson/primitive"
// GetSellerByIDRequest ...
type GetSellerByIDRequest struct {
SellerID primitive.ObjectID `json:"sellerId"`
}

8
model/seller_response.go Normal file
View File

@ -0,0 +1,8 @@
package model
// ResponseSellerInfo ...
type ResponseSellerInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
}

View File

@ -7,6 +7,7 @@ var prefixes = struct {
Location string Location string
Bank string Bank string
Supplier string Supplier string
Seller string
}{ }{
Communication: "communication", Communication: "communication",
Order: "order", Order: "order",
@ -14,4 +15,5 @@ var prefixes = struct {
Location: "location", Location: "location",
Supplier: "supplier", Supplier: "supplier",
Bank: "bank", Bank: "bank",
Seller: "seller",
} }

14
subject/seller.go Normal file
View File

@ -0,0 +1,14 @@
package subject
import "fmt"
func getSellerValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Seller, val)
}
// Seller ...
var Seller = struct {
GetSellerInfoByID string
}{
GetSellerInfoByID: getSellerValue("get_seller_info_by_id"),
}