[Update] Action create + update warehouse #16

Merged
trunglt251292 merged 1 commits from warehouse-nats into develop 2022-08-31 09:51:59 +00:00
2 changed files with 40 additions and 0 deletions
Showing only changes of commit e0a4a508a6 - Show all commits

View File

@ -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))

View File

@ -15,7 +15,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"),