[Update] Action create + update warehouse
This commit is contained in:
		
							parent
							
								
									8cdfdcb4e6
								
							
						
					
					
						commit
						e0a4a508a6
					
				| 
						 | 
				
			
			@ -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))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue