Merge branch 'location-by-ward-code' into develop

This commit is contained in:
quang 2023-02-03 17:21:15 +07:00
commit 2e96466d4c
2 changed files with 23 additions and 0 deletions

View File

@ -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))

View File

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