refactor-location #134

Closed
trunglam wants to merge 270 commits from refactor-location into master
5 changed files with 15 additions and 27 deletions
Showing only changes of commit 73e2a8a7c8 - Show all commits

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,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

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 {
SupplierID string `json:"supplierId"`
Freeships []Freeship `json:"freeships"`
type SupplierFreeShipInfoResponse struct {
SupplierID string `json:"supplierId"`
FreeShip FreeShip `json:"freeShip"`
}

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"),
}