init #139
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -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))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue