init #139

Merged
trunglam merged 1 commits from location-by-ward-code into master 2023-02-06 02:29:04 +00:00
2 changed files with 23 additions and 0 deletions
Showing only changes of commit dba7cf4691 - Show all commits

View File

@ -38,6 +38,27 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode
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 ...
func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) {
msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodesFromLocationService, toBytes(p))

View File

@ -9,6 +9,7 @@ func getLocationValue(val string) string {
var Location = struct {
GetLocationByCode string
GetLocationByCodeFromLocationService string
GetLocationByWardCode string
GetProvincesByCodes string
GetProvincesByCodesFromLocationService string
GetDistrictsByCodes string
@ -28,6 +29,7 @@ var Location = struct {
}{
GetLocationByCode: getLocationValue("get_location_warehouse"),
GetLocationByCodeFromLocationService: getLocationValue("get_location_warehouse_from_location_service"),
GetLocationByWardCode: getLocationValue("get_location_by_ward_code"),
GetProvincesByCodes: getLocationValue("get_provinces_by_codes"),
GetProvincesByCodesFromLocationService: getLocationValue("get_provinces_by_codes_from_location_service"),
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),