Merge pull request 'add get-detail-supplier-info' (#124) from setup-holiday-supplier-tool into develop
Reviewed-on: #124
This commit is contained in:
commit
8d20189418
|
@ -39,6 +39,28 @@ func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) ([]*model.Resp
|
|||
return r.Data, nil
|
||||
}
|
||||
|
||||
// GetDetailSupplierInfo ...
|
||||
func (s Supplier) GetDetailSupplierInfo(p model.GetDetailSupplierRequest) (*model.ResponseSupplierInfo, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.Supplier.GetDetailSupplierInfo, toBytes(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r struct {
|
||||
Data *model.ResponseSupplierInfo `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
|
||||
}
|
||||
|
||||
func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractRequest) (*model.ResponseSupplierContract, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierContractBySupplierID, toBytes(p))
|
||||
if err != nil {
|
||||
|
|
|
@ -9,6 +9,11 @@ type GetSupplierRequest struct {
|
|||
ListID []primitive.ObjectID `json:"listID"`
|
||||
}
|
||||
|
||||
// GetDetailSupplierRequest ...
|
||||
type GetDetailSupplierRequest struct {
|
||||
Supplier string `json:"supplier"`
|
||||
}
|
||||
|
||||
type GetSupplierContractRequest struct {
|
||||
SupplierID primitive.ObjectID `json:"supplierID"`
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ func getSupplierValue(val string) string {
|
|||
|
||||
var Supplier = struct {
|
||||
GetListSupplierInfo string
|
||||
GetDetailSupplierInfo string
|
||||
GetSupplierContractBySupplierID string
|
||||
FindAll string
|
||||
GetListWarehouseFreeShip string
|
||||
|
@ -20,6 +21,7 @@ var Supplier = struct {
|
|||
Count string
|
||||
}{
|
||||
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
|
||||
GetDetailSupplierInfo: getSupplierValue("get_detail_supplier_info"),
|
||||
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
|
||||
FindAll: getSupplierValue("find_all"),
|
||||
GetListWarehouseFreeShip: getSupplierValue("get_list_warehouse_free_ship"),
|
||||
|
|
Loading…
Reference in New Issue