update location add slug & DistinctWithField

This commit is contained in:
quang1472001 2022-10-06 10:55:49 +07:00
parent b9b55d144e
commit cebb3214cf
3 changed files with 62 additions and 29 deletions

View File

@ -293,3 +293,22 @@ func (l Location) CountWardByCondition(p model.WardRequestCondition) (int64, err
} }
return r.Data, nil return r.Data, nil
} }
// DistinctWithField ...
func (l Location) DistinctWithField(p model.ProvinceDistinctWithField) ([]interface{}, error) {
msg, err := natsio.GetServer().Request(subject.Location.ProvinceDistinctWithField, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []interface{} `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
}

View File

@ -18,6 +18,7 @@ type (
Code int `json:"code"` Code int `json:"code"`
Codes []int `json:"codes"` Codes []int `json:"codes"`
Slug string `json:"slug"` Slug string `json:"slug"`
Slugs []string `json:"slugs"`
} }
// DistrictRequestPayload ... // DistrictRequestPayload ...
@ -31,6 +32,7 @@ type (
Codes []int `json:"codes"` Codes []int `json:"codes"`
ProvinceCode int `json:"provinceCode"` ProvinceCode int `json:"provinceCode"`
Slug string `json:"slug"` Slug string `json:"slug"`
ProvinceSlug string `json:"provinceSlug"`
} }
// WardRequestPayload ... // WardRequestPayload ...
@ -45,5 +47,15 @@ type (
DistrictCode int `json:"districtCode"` DistrictCode int `json:"districtCode"`
ProvinceCode int `json:"provinceCode"` ProvinceCode int `json:"provinceCode"`
Slug string `json:"slug"` Slug string `json:"slug"`
DistrictSlug string `json:"districtSlug"`
ProvinceSlug string `json:"provinceSlug"`
}
// ProvinceDistinctWithField ...
ProvinceDistinctWithField struct {
Conditions struct {
Region string `json:"region"`
} `json:"conditions"`
Field string `json:"filed"`
} }
) )

View File

@ -20,6 +20,7 @@ var Location = struct {
CountProvinceByCondition string CountProvinceByCondition string
CountDistrictByCondition string CountDistrictByCondition string
CountWardByCondition string CountWardByCondition string
ProvinceDistinctWithField string
}{ }{
GetLocationByCode: getLocationValue("get_location_warehouse"), GetLocationByCode: getLocationValue("get_location_warehouse"),
GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), GetProvincesByCodes: getLocationValue("get_provinces_by_codes"),
@ -34,4 +35,5 @@ var Location = struct {
CountProvinceByCondition: getLocationValue("count_province_by_condition"), CountProvinceByCondition: getLocationValue("count_province_by_condition"),
CountDistrictByCondition: getLocationValue("count_district_by_condition"), CountDistrictByCondition: getLocationValue("count_district_by_condition"),
CountWardByCondition: getLocationValue("count_ward_by_condition"), CountWardByCondition: getLocationValue("count_ward_by_condition"),
ProvinceDistinctWithField: getLocationValue("province_distinct_with_field"),
} }