refactor-code

This commit is contained in:
phuanbui 2022-08-26 17:36:02 +07:00
parent cab7525f50
commit d79739aa0f
5 changed files with 28 additions and 14 deletions

View File

@ -18,7 +18,7 @@ func GetLocation() Location {
} }
func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) { func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) {
msg, err := natsio.GetServer().Request(subject.GetLocationWarehouse, toBytes(payload)) msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCode, toBytes(payload))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -13,7 +13,7 @@ import (
type Supplier struct{} type Supplier struct{}
func (s Supplier) GetSupplierInfo(supplierID string) (*model.ResponseSupplierInfo, error) { func (s Supplier) GetSupplierInfo(supplierID string) (*model.ResponseSupplierInfo, error) {
msg, err := natsio.GetServer().Request(subject.GetSupplierInfo, toBytes(supplierID)) msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierInfo, toBytes(supplierID))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -4,8 +4,12 @@ var prefixes = struct {
Communication string Communication string
Order string Order string
Warehouse string Warehouse string
Location string
Supplier string
}{ }{
Communication: "communication", Communication: "communication",
Order: "order", Order: "order",
Warehouse: "warehouse", Warehouse: "warehouse",
Location: "location",
Supplier: "supplier",
} }

View File

@ -1,8 +1,13 @@
package subject package subject
const ( import "fmt"
locationPrefix = "location_"
) func getLocationValue(val string) string {
const ( return fmt.Sprintf("%s.%s", prefixes.Location, val)
GetLocationWarehouse = locationPrefix + "get_address" }
)
var Location = struct {
GetLocationByCode string
}{
GetLocationByCode: getLocationValue("get_location_warehouse"),
}

View File

@ -1,8 +1,13 @@
package subject package subject
const ( import "fmt"
supplierPrefix = "supplier"
) func getSupplierValue(val string) string {
const ( return fmt.Sprintf("%s.%s", prefixes.Supplier, val)
GetSupplierInfo = supplierPrefix + "get_info" }
)
var Supplier = struct {
GetSupplierInfo string
}{
GetSupplierInfo: getSupplierValue("get_supplier_info"),
}