define warehouse method
This commit is contained in:
		
							parent
							
								
									cc89feac0d
								
							
						
					
					
						commit
						aab1103fc8
					
				| 
						 | 
					@ -144,3 +144,22 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return r.Data, nil
 | 
						return r.Data, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetWarehouses ...
 | 
				
			||||||
 | 
					func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWarehousesResponse, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.GetWarehousesResponse `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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,3 +80,14 @@ type SupplierIsClosed struct {
 | 
				
			||||||
	Supplier string `json:"supplier"`
 | 
						Supplier string `json:"supplier"`
 | 
				
			||||||
	IsClosed bool   `json:"isClosed"`
 | 
						IsClosed bool   `json:"isClosed"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetWarehousesRequest ...
 | 
				
			||||||
 | 
					type GetWarehousesRequest struct {
 | 
				
			||||||
 | 
						Keyword      string `json:"keyword"`
 | 
				
			||||||
 | 
						Status       string `json:"status"`
 | 
				
			||||||
 | 
						Supplier     string `json:"supplier"`
 | 
				
			||||||
 | 
						BusinessType string `json:"businessType"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Page  int64 `json:"page"`
 | 
				
			||||||
 | 
						Limit int64 `json:"limit"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,3 +135,30 @@ type WarehouseNatsResponse struct {
 | 
				
			||||||
	CreatedAt      time.Time                 `json:"createdAt"`
 | 
						CreatedAt      time.Time                 `json:"createdAt"`
 | 
				
			||||||
	UpdatedAt      time.Time                 `json:"updatedAt"`
 | 
						UpdatedAt      time.Time                 `json:"updatedAt"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// WarehouseInfo ...
 | 
				
			||||||
 | 
					type WarehouseInfo struct {
 | 
				
			||||||
 | 
						ID           string                    `json:"_id"`
 | 
				
			||||||
 | 
						Name         string                    `json:"name"`
 | 
				
			||||||
 | 
						BusinessType string                    `json:"businessType"`
 | 
				
			||||||
 | 
						Status       string                    `json:"status"`
 | 
				
			||||||
 | 
						Slug         string                    `json:"slug"`
 | 
				
			||||||
 | 
						Supplier     WarehouseSupplierInfo     `json:"supplier"`
 | 
				
			||||||
 | 
						Location     ResponseWarehouseLocation `json:"location"`
 | 
				
			||||||
 | 
						Contact      ResponseWarehouseContact  `json:"contact"`
 | 
				
			||||||
 | 
						CreatedAt    string                    `json:"createdAt"`
 | 
				
			||||||
 | 
						UpdatedAt    string                    `json:"updatedAt"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// WarehouseSupplierInfo ...
 | 
				
			||||||
 | 
					type WarehouseSupplierInfo struct {
 | 
				
			||||||
 | 
						ID   string `json:"_id"`
 | 
				
			||||||
 | 
						Name string `json:"name"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetWarehousesResponse ...
 | 
				
			||||||
 | 
					type GetWarehousesResponse struct {
 | 
				
			||||||
 | 
						Total int64           `json:"total"`
 | 
				
			||||||
 | 
						Limit int64           `json:"limit"`
 | 
				
			||||||
 | 
						List  []WarehouseInfo `json:"list"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,7 @@ var Warehouse = struct {
 | 
				
			||||||
	AfterUpdateWarehouse          string
 | 
						AfterUpdateWarehouse          string
 | 
				
			||||||
	AfterCreateWarehouse          string
 | 
						AfterCreateWarehouse          string
 | 
				
			||||||
	UpdateIsClosedSupplier        string
 | 
						UpdateIsClosedSupplier        string
 | 
				
			||||||
 | 
						GetWarehouses                 string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	AfterCreateWarehouse:          getWarehouseValue("after_create_warehouse"),
 | 
						AfterCreateWarehouse:          getWarehouseValue("after_create_warehouse"),
 | 
				
			||||||
	AfterUpdateWarehouse:          getWarehouseValue("after_update_warehouse"),
 | 
						AfterUpdateWarehouse:          getWarehouseValue("after_update_warehouse"),
 | 
				
			||||||
| 
						 | 
					@ -36,4 +37,5 @@ var Warehouse = struct {
 | 
				
			||||||
	Distinct:                      getWarehouseValue("distinct"),
 | 
						Distinct:                      getWarehouseValue("distinct"),
 | 
				
			||||||
	Count:                         getWarehouseValue("count"),
 | 
						Count:                         getWarehouseValue("count"),
 | 
				
			||||||
	UpdateIsClosedSupplier:        getWarehouseValue("update_is_closed_supplier"),
 | 
						UpdateIsClosedSupplier:        getWarehouseValue("update_is_closed_supplier"),
 | 
				
			||||||
 | 
						GetWarehouses:                 getWarehouseValue("get_warehouses"),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue