build nats supplier

This commit is contained in:
Tue 2022-08-31 14:41:06 +07:00
parent ed48d80665
commit d29ad11fa5
1 changed files with 21 additions and 0 deletions

View File

@ -38,6 +38,27 @@ func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) ([]*model.Resp
return r.Data, nil 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
}
func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) { func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID))
if err != nil { if err != nil {