fix get supplier #9
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -17,8 +17,8 @@ func GetSupplier() Supplier {
 | 
			
		|||
	return Supplier{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s Supplier) GetSupplierInfo(supplierID model.GetSupplierRequest) (*model.ResponseSupplierInfo, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierInfo, toBytes(supplierID))
 | 
			
		||||
func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) (*model.ResponseSupplierInfo, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.Supplier.GetListSupplierInfo, toBytes(p))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -37,3 +37,24 @@ func (s Supplier) GetSupplierInfo(supplierID model.GetSupplierRequest) (*model.R
 | 
			
		|||
 | 
			
		||||
	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 {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Data  *model.ResponseSupplierContract `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,5 +6,9 @@ import (
 | 
			
		|||
 | 
			
		||||
// GetSupplierRequest ...
 | 
			
		||||
type GetSupplierRequest struct {
 | 
			
		||||
	ID primitive.ObjectID `json:"_id"`
 | 
			
		||||
	ListID []primitive.ObjectID `json:"listID"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetSupplierContractRequest struct {
 | 
			
		||||
	SupplierID primitive.ObjectID `json:"supplierID"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,3 +5,11 @@ type ResponseSupplierInfo struct {
 | 
			
		|||
	ID   string `json:"id"`
 | 
			
		||||
	Name string `json:"name"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ResponseSupplierContract ...
 | 
			
		||||
type ResponseSupplierContract struct {
 | 
			
		||||
	ID       string `json:"id"`
 | 
			
		||||
	Supplier string `json:"supplier"`
 | 
			
		||||
	Name     string `json:"name"`
 | 
			
		||||
	Status   string `json:"status"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,9 @@ func getSupplierValue(val string) string {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
var Supplier = struct {
 | 
			
		||||
	GetSupplierInfo string
 | 
			
		||||
	GetListSupplierInfo             string
 | 
			
		||||
	GetSupplierContractBySupplierID string
 | 
			
		||||
}{
 | 
			
		||||
	GetSupplierInfo: getSupplierValue("get_supplier_info"),
 | 
			
		||||
	GetListSupplierInfo:             getSupplierValue("get_list_supplier_info"),
 | 
			
		||||
	GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue