From 73e2a8a7c8fc2ad12e37cef28d0968d598aca964 Mon Sep 17 00:00:00 2001 From: QuanTT0110 Date: Thu, 27 Oct 2022 15:52:39 +0700 Subject: [PATCH] get supplier freeship info --- client/supplier.go | 12 ++++++------ model/supplier_request.go | 4 ++-- model/supplier_response.go | 9 +++++---- subject/selly.go | 15 --------------- subject/supplier.go | 2 ++ 5 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 subject/selly.go diff --git a/client/supplier.go b/client/supplier.go index 5d14796..38619c1 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -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,15 +139,15 @@ 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"` - Error string `json:"error"` + Data []*model.SupplierFreeShipInfoResponse `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err diff --git a/model/supplier_request.go b/model/supplier_request.go index c76f195..c461656 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -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"` } diff --git a/model/supplier_response.go b/model/supplier_response.go index aabd6f3..d1cb146 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -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 { - SupplierID string `json:"supplierId"` - Freeships []Freeship `json:"freeships"` +type SupplierFreeShipInfoResponse struct { + SupplierID string `json:"supplierId"` + FreeShip FreeShip `json:"freeShip"` } diff --git a/subject/selly.go b/subject/selly.go deleted file mode 100644 index f4b6010..0000000 --- a/subject/selly.go +++ /dev/null @@ -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"), -} diff --git a/subject/supplier.go b/subject/supplier.go index da95ef9..a581494 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -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"), }