Merge branch 'feature/get-freeship-info' of git.selly.red:Selly-Modules/natsio into develop

This commit is contained in:
QuanTT0110 2022-10-27 17:17:02 +07:00
commit 0dafeb6f1f
5 changed files with 14 additions and 26 deletions

View File

@ -119,7 +119,7 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh
// GetWarehouseFreeship ...
func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusinessType, error) {
msg, err := natsio.GetServer().Request(subject.Selly.GetListWarehouseFreeship, toBytes(bson.M{}))
msg, err := natsio.GetServer().Request(subject.Supplier.GetListWarehouseFreeship, toBytes(bson.M{}))
if err != nil {
return nil, err
}
@ -139,14 +139,14 @@ func (s Supplier) GetWarehouseFreeship() (*model.ResponseListWarehouseIDByBusine
return r.Data, nil
}
// GetFreeshipsBySupplierIDs ...
func (s Supplier) GetFreeshipsBySupplierIDs(p model.GetFreeshipsBySupplierIds) (*model.ResponseListFreeshipsBySupplierIds, error) {
msg, err := natsio.GetServer().Request(subject.Selly.GetFreeshipsBySupplierIds, toBytes(p))
// GetFreeShipInfo ...
func (s Supplier) GetFreeShipInfo(p []model.SupplierFreeShipInfoRequestPayload) ([]*model.SupplierFreeShipInfoResponse, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.GetFreeShipInfo, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseListFreeshipsBySupplierIds `json:"data"`
Data []*model.SupplierFreeShipInfoResponse `json:"data"`
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {

View File

@ -49,6 +49,6 @@ type SupplierCashflowCreatePayload struct {
ClickAction *ClickAction `json:"clickAction"`
}
type GetFreeshipsBySupplierIds struct {
SupplierIDs []string `json:"supplierIds"`
type SupplierFreeShipInfoRequestPayload struct {
SupplierID string `json:"supplierId"`
}

View File

@ -38,13 +38,14 @@ type SupplierCashflowCreateResponse struct {
ID string `json:"id"`
}
type Freeship struct {
type FreeShip struct {
ID string `json:"_id"`
ShortName string `json:"shortName"`
MilestoneText []string `json:"milestoneText"`
Order int `json:"-"`
}
type ResponseListFreeshipsBySupplierIds struct {
type SupplierFreeShipInfoResponse struct {
SupplierID string `json:"supplierId"`
Freeships []Freeship `json:"freeships"`
FreeShips []FreeShip `json:"freeShips"`
}

View File

@ -1,15 +0,0 @@
package subject
import "fmt"
func getSellyValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Selly, val)
}
var Selly = struct {
GetFreeshipsBySupplierIds string
GetListWarehouseFreeship string
}{
GetFreeshipsBySupplierIds: getSellyValue("get_freeships_by_supplier_ids"),
GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"),
}

View File

@ -12,10 +12,12 @@ var Supplier = struct {
FindAll string
GetListWarehouseFreeship string
CreateCashflow string
GetFreeShipInfo string
}{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"),
GetListWarehouseFreeship: getSupplierValue("get_list_warehouse_freeship"),
CreateCashflow: getSupplierValue("create_cashflow"),
GetFreeShipInfo: getSupplierValue("get_free_ship_info"),
}