init #139
|
@ -38,6 +38,27 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode
|
||||||
return r.Data, nil
|
return r.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLocationByWardCode ...
|
||||||
|
func (l Location) GetLocationByWardCode(payload model.RequestCondition) (*model.ResponseLocationAddress, error) {
|
||||||
|
msg, err := natsio.GetServer().Request(subject.Location.GetLocationByWardCode, toBytes(payload))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var r struct {
|
||||||
|
Data *model.ResponseLocationAddress `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
|
||||||
|
}
|
||||||
|
|
||||||
// GetProvincesByCodes ...
|
// GetProvincesByCodes ...
|
||||||
func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) {
|
func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) {
|
||||||
msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodesFromLocationService, toBytes(p))
|
msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodesFromLocationService, toBytes(p))
|
||||||
|
|
|
@ -9,6 +9,7 @@ func getLocationValue(val string) string {
|
||||||
var Location = struct {
|
var Location = struct {
|
||||||
GetLocationByCode string
|
GetLocationByCode string
|
||||||
GetLocationByCodeFromLocationService string
|
GetLocationByCodeFromLocationService string
|
||||||
|
GetLocationByWardCode string
|
||||||
GetProvincesByCodes string
|
GetProvincesByCodes string
|
||||||
GetProvincesByCodesFromLocationService string
|
GetProvincesByCodesFromLocationService string
|
||||||
GetDistrictsByCodes string
|
GetDistrictsByCodes string
|
||||||
|
@ -28,6 +29,7 @@ var Location = struct {
|
||||||
}{
|
}{
|
||||||
GetLocationByCode: getLocationValue("get_location_warehouse"),
|
GetLocationByCode: getLocationValue("get_location_warehouse"),
|
||||||
GetLocationByCodeFromLocationService: getLocationValue("get_location_warehouse_from_location_service"),
|
GetLocationByCodeFromLocationService: getLocationValue("get_location_warehouse_from_location_service"),
|
||||||
|
GetLocationByWardCode: getLocationValue("get_location_by_ward_code"),
|
||||||
GetProvincesByCodes: getLocationValue("get_provinces_by_codes"),
|
GetProvincesByCodes: getLocationValue("get_provinces_by_codes"),
|
||||||
GetProvincesByCodesFromLocationService: getLocationValue("get_provinces_by_codes_from_location_service"),
|
GetProvincesByCodesFromLocationService: getLocationValue("get_provinces_by_codes_from_location_service"),
|
||||||
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),
|
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),
|
||||||
|
|
Loading…
Reference in New Issue