add get,create, update supplier-holiday
This commit is contained in:
parent
1f4edb64ab
commit
067db84489
|
@ -182,3 +182,66 @@ func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatu
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateSupplierHoliday ...
|
||||||
|
func (w Warehouse) CreateSupplierHoliday(p model.SupplierHolidayCreatePayload) error {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateSupplierHoliday, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return fmt.Errorf("nats: create_supplier_holiday %v", err)
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return errors.New(r.Error)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateSupplierHoliday ...
|
||||||
|
func (w Warehouse) UpdateSupplierHoliday(p model.SupplierHolidayUpdatePayload) error {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateSupplierHoliday, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(msg.Data, &r); err != nil {
|
||||||
|
return fmt.Errorf("nats: create_supplier_holiday %v", err)
|
||||||
|
}
|
||||||
|
if r.Error != "" {
|
||||||
|
return errors.New(r.Error)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSupplierHoliday ...
|
||||||
|
func (w Warehouse) GetSupplierHoliday(p model.GetSupplierHolidayRequest) (*model.ResponseSupplierHoliday, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Warehouse.GetSupplierHoliday, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r struct {
|
||||||
|
Data *model.ResponseSupplierHoliday `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
|
||||||
|
}
|
||||||
|
|
|
@ -113,3 +113,28 @@ type WarehouseORUpdateDeliveryStatus struct {
|
||||||
OrderID string `json:"orderId"`
|
OrderID string `json:"orderId"`
|
||||||
DeliveryStatus string `json:"deliveryStatus"`
|
DeliveryStatus string `json:"deliveryStatus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SupplierHolidayCreatePayload ...
|
||||||
|
type SupplierHolidayCreatePayload struct {
|
||||||
|
Supplier string `json:"supplier"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
From string `json:"from"`
|
||||||
|
To string `json:"to"`
|
||||||
|
Warehouses []string `json:"warehouses"`
|
||||||
|
IsApplyAll bool `json:"isApplyAll"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupplierHolidayUpdatePayload ...
|
||||||
|
type SupplierHolidayUpdatePayload struct {
|
||||||
|
Supplier string `json:"supplier"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
From string `json:"from"`
|
||||||
|
To string `json:"to"`
|
||||||
|
Warehouses []string `json:"warehouses"`
|
||||||
|
IsApplyAll bool `json:"isApplyAll"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSupplierHolidayRequest ...
|
||||||
|
type GetSupplierHolidayRequest struct {
|
||||||
|
Conditions interface{} `json:"conditions"`
|
||||||
|
}
|
||||||
|
|
|
@ -172,3 +172,20 @@ type GetWarehousesResponse struct {
|
||||||
Limit int64 `json:"limit"`
|
Limit int64 `json:"limit"`
|
||||||
List []WarehouseInfo `json:"list"`
|
List []WarehouseInfo `json:"list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResponseWarehouseShort ...
|
||||||
|
type ResponseWarehouseShort struct {
|
||||||
|
ID string `json:"_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResponseSupplierHoliday ...
|
||||||
|
type ResponseSupplierHoliday struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
From string `json:"from"`
|
||||||
|
To string `json:"to"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
IsApplyAll bool `json:"isApplyAll"`
|
||||||
|
Warehouses []ResponseWarehouseShort `json:"warehouses"`
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ var Warehouse = struct {
|
||||||
UpdateIsClosedSupplier string
|
UpdateIsClosedSupplier string
|
||||||
GetWarehouses string
|
GetWarehouses string
|
||||||
UpdateORDeliveryStatus string
|
UpdateORDeliveryStatus string
|
||||||
|
CreateSupplierHoliday string
|
||||||
|
UpdateSupplierHoliday string
|
||||||
|
GetSupplierHoliday string
|
||||||
}{
|
}{
|
||||||
CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"),
|
CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"),
|
||||||
UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"),
|
UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"),
|
||||||
|
@ -46,4 +49,7 @@ var Warehouse = struct {
|
||||||
UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"),
|
UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"),
|
||||||
GetWarehouses: getWarehouseValue("get_warehouses"),
|
GetWarehouses: getWarehouseValue("get_warehouses"),
|
||||||
UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"),
|
UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"),
|
||||||
|
CreateSupplierHoliday: getWarehouseValue("create_supplier_holiday"),
|
||||||
|
UpdateSupplierHoliday: getWarehouseValue("update_supplier_holiday"),
|
||||||
|
GetSupplierHoliday: getWarehouseValue("get_supplier_holiday"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue