Merge branch 'master' into feature/seller-by-id
This commit is contained in:
commit
e16a537ed2
|
@ -0,0 +1,36 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"github.com/Selly-Modules/natsio"
|
||||||
|
"github.com/Selly-Modules/natsio/model"
|
||||||
|
"github.com/Selly-Modules/natsio/subject"
|
||||||
|
)
|
||||||
|
|
||||||
|
// News ...
|
||||||
|
type News struct{}
|
||||||
|
|
||||||
|
// GetNews ...
|
||||||
|
func GetNews() News {
|
||||||
|
return News{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetProductNoticesByInventory ...
|
||||||
|
func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, toBytes(p))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var r struct {
|
||||||
|
Data *model.GetProductNoticesByInventoryResponse `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
|
||||||
|
}
|
|
@ -17,6 +17,24 @@ func GetWarehouse() Warehouse {
|
||||||
return Warehouse{}
|
return Warehouse{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateIsClosedSupplier ...
|
||||||
|
func (w Warehouse) UpdateIsClosedSupplier(p model.UpdateSupplierIsClosedRequest) error {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateIsClosedSupplier, 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
|
||||||
|
}
|
||||||
|
|
||||||
// AfterCreateWarehouse ...
|
// AfterCreateWarehouse ...
|
||||||
func (w Warehouse) AfterCreateWarehouse(p model.WarehouseNatsResponse) error {
|
func (w Warehouse) AfterCreateWarehouse(p model.WarehouseNatsResponse) error {
|
||||||
msg, err := natsio.GetServer().Request(subject.Warehouse.AfterCreateWarehouse, toBytes(p))
|
msg, err := natsio.GetServer().Request(subject.Warehouse.AfterCreateWarehouse, toBytes(p))
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
// GetProductNoticesByInventoryRequest ....
|
||||||
|
type GetProductNoticesByInventoryRequest struct {
|
||||||
|
InventoryIds []string `json:"inventoryIds"`
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
// GetProductNoticesByInventoryResponse ....
|
||||||
|
type GetProductNoticesByInventoryResponse struct {
|
||||||
|
Notices []NewsAppResponse `json:"notices"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewsAppResponse ...
|
||||||
|
type NewsAppResponse struct {
|
||||||
|
ID string `json:"_id"`
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
Target *TargetNewDoc `json:"target,omitempty"`
|
||||||
|
ActionType *ActionType `json:"action"`
|
||||||
|
ShortDesc string `json:"shortDesc,omitempty"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
ShortTitle string `json:"shortTitle,omitempty"`
|
||||||
|
Color string `json:"color"`
|
||||||
|
Options *NewsOptions `json:"options,omitempty"`
|
||||||
|
DisplayStyle string `json:"displayStyle"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewsOptions ...
|
||||||
|
type NewsOptions struct {
|
||||||
|
Category string `json:"category"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TargetNewDoc ...
|
||||||
|
type TargetNewDoc struct {
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActionType ...
|
||||||
|
type ActionType struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
Text string `json:"text,omitempty"`
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ package model
|
||||||
type ResponseSupplierInfo struct {
|
type ResponseSupplierInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
BusinessType string `json:"businessType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResponseSupplierContract ...
|
// ResponseSupplierContract ...
|
||||||
|
@ -19,6 +20,7 @@ type SupplierBrief struct {
|
||||||
ID string `json:"_id"`
|
ID string `json:"_id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
BusinessType string `json:"businessType"`
|
||||||
CreatedAt string `json:"createdAt"`
|
CreatedAt string `json:"createdAt"`
|
||||||
UpdatedAt string `json:"updatedAt"`
|
UpdatedAt string `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,3 +69,14 @@ type SyncORStatusRequest struct {
|
||||||
ORCode string `json:"orCode"`
|
ORCode string `json:"orCode"`
|
||||||
OrderCode string `json:"orderCode"`
|
OrderCode string `json:"orderCode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateSupplierIsClosedRequest ...
|
||||||
|
type UpdateSupplierIsClosedRequest struct {
|
||||||
|
Suppliers []SupplierIsClosed `json:"suppliers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupplierIsClosed ...
|
||||||
|
type SupplierIsClosed struct {
|
||||||
|
Supplier string `json:"supplier"`
|
||||||
|
IsClosed bool `json:"isClosed"`
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,20 @@ type WarehouseConfiguration struct {
|
||||||
Partner WarehousePartner `json:"partner"`
|
Partner WarehousePartner `json:"partner"`
|
||||||
Delivery WarehouseDelivery `json:"delivery"`
|
Delivery WarehouseDelivery `json:"delivery"`
|
||||||
Other WarehouseOther `json:"other"`
|
Other WarehouseOther `json:"other"`
|
||||||
|
Food WarehouseFood `json:"food"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WarehouseFood ...
|
||||||
|
type WarehouseFood struct {
|
||||||
|
ForceClosed bool `json:"forceClosed"`
|
||||||
|
IsClosed bool `json:"isClosed"`
|
||||||
|
TimeRange []TimeRange `json:"timeRange"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimeRange ...
|
||||||
|
type TimeRange struct {
|
||||||
|
From int64 `json:"from"`
|
||||||
|
To int64 `json:"to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarehouseOther ...
|
// WarehouseOther ...
|
||||||
|
@ -109,6 +123,7 @@ type ResponseLatLng struct {
|
||||||
type WarehouseNatsResponse struct {
|
type WarehouseNatsResponse struct {
|
||||||
ID string `json:"_id"`
|
ID string `json:"_id"`
|
||||||
Staff string `json:"staff"`
|
Staff string `json:"staff"`
|
||||||
|
BusinessType string `json:"businessType"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
SearchString string `json:"searchString"`
|
SearchString string `json:"searchString"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
|
|
|
@ -3,6 +3,7 @@ package subject
|
||||||
var prefixes = struct {
|
var prefixes = struct {
|
||||||
Communication string
|
Communication string
|
||||||
Order string
|
Order string
|
||||||
|
News string
|
||||||
Warehouse string
|
Warehouse string
|
||||||
Location string
|
Location string
|
||||||
Supplier string
|
Supplier string
|
||||||
|
@ -10,6 +11,7 @@ var prefixes = struct {
|
||||||
}{
|
}{
|
||||||
Communication: "communication",
|
Communication: "communication",
|
||||||
Order: "order",
|
Order: "order",
|
||||||
|
News: "news",
|
||||||
Warehouse: "warehouse",
|
Warehouse: "warehouse",
|
||||||
Location: "location",
|
Location: "location",
|
||||||
Supplier: "supplier",
|
Supplier: "supplier",
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package subject
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func getNewsValue(val string) string {
|
||||||
|
return fmt.Sprintf("%s.%s", prefixes.News, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
var News = struct {
|
||||||
|
GetProductNoticesByInventory string
|
||||||
|
}{
|
||||||
|
GetProductNoticesByInventory: getNewsValue("get_product_notices_by_inventory"),
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ var Warehouse = struct {
|
||||||
Count string
|
Count string
|
||||||
AfterUpdateWarehouse string
|
AfterUpdateWarehouse string
|
||||||
AfterCreateWarehouse string
|
AfterCreateWarehouse string
|
||||||
|
UpdateIsClosedSupplier string
|
||||||
}{
|
}{
|
||||||
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
|
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
|
||||||
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
|
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
|
||||||
|
@ -34,4 +35,5 @@ var Warehouse = struct {
|
||||||
FindByCondition: getWarehouseValue("find_all_by_condition"),
|
FindByCondition: getWarehouseValue("find_all_by_condition"),
|
||||||
Distinct: getWarehouseValue("distinct"),
|
Distinct: getWarehouseValue("distinct"),
|
||||||
Count: getWarehouseValue("count"),
|
Count: getWarehouseValue("count"),
|
||||||
|
UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue