feat(warehouse): add warehouse method get list config

This commit is contained in:
Sinh 2024-04-08 15:40:13 +07:00
parent 524db8391f
commit 9004771704
1 changed files with 19 additions and 0 deletions

View File

@ -146,6 +146,25 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC
return r.Data, nil return r.Data, nil
} }
// GetListConfig ...
func (w Warehouse) GetListConfig(req model.GetListWarehouseConfigReq) ([]*model.WarehouseConfiguration, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.GetListWarehouseConfig, toBytes(req))
if err != nil {
return nil, err
}
var r struct {
Data []*model.WarehouseConfiguration `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
}
// GetWarehouses ... // GetWarehouses ...
func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWarehousesResponse, error) { func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWarehousesResponse, error) {
msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p))