Merge pull request #16 from Selly-Modules/warehouse-nats
[Update] Action create + update warehouse
This commit is contained in:
commit
d65c98f646
|
@ -17,6 +17,42 @@ func GetWarehouse() Warehouse {
|
|||
return Warehouse{}
|
||||
}
|
||||
|
||||
// AfterCreateWarehouse ...
|
||||
func (w Warehouse) AfterCreateWarehouse(p model.WarehouseNatsResponse) error {
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.AfterCreateWarehouse, toBytes(p))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var r struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Error != "" {
|
||||
return errors.New(r.Error)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AfterUpdateWarehouse ...
|
||||
func (w Warehouse) AfterUpdateWarehouse(p model.WarehouseNatsResponse) error {
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.AfterUpdateWarehouse, toBytes(p))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var r struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Error != "" {
|
||||
return errors.New(r.Error)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateOutboundRequest ...
|
||||
func (w Warehouse) CreateOutboundRequest(p model.OutboundRequestPayload) (*model.OutboundRequestResponse, error) {
|
||||
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateOutboundRequest, toBytes(p))
|
||||
|
|
|
@ -18,7 +18,11 @@ var Warehouse = struct {
|
|||
FindByCondition string
|
||||
Distinct string
|
||||
Count string
|
||||
AfterUpdateWarehouse string
|
||||
AfterCreateWarehouse string
|
||||
}{
|
||||
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
|
||||
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
|
||||
CreateOutboundRequest: getWarehouseValue("create_outbound_request"),
|
||||
UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"),
|
||||
CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"),
|
||||
|
|
Loading…
Reference in New Issue