update location add slug & DistinctWithField
This commit is contained in:
parent
b9b55d144e
commit
cebb3214cf
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -15,9 +15,10 @@ type (
|
||||||
|
|
||||||
// ProvinceRequestCondition ...
|
// ProvinceRequestCondition ...
|
||||||
ProvinceRequestCondition struct {
|
ProvinceRequestCondition struct {
|
||||||
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"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,31 +7,33 @@ func getLocationValue(val string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var Location = struct {
|
var Location = struct {
|
||||||
GetLocationByCode string
|
GetLocationByCode string
|
||||||
GetProvincesByCodes string
|
GetProvincesByCodes string
|
||||||
GetDistrictsByCodes string
|
GetDistrictsByCodes string
|
||||||
GetWardsByCodes string
|
GetWardsByCodes string
|
||||||
GetProvinceByCondition string
|
GetProvinceByCondition string
|
||||||
GetProvincesByCondition string
|
GetProvincesByCondition string
|
||||||
GetDistrictByCondition string
|
GetDistrictByCondition string
|
||||||
GetDistrictsByCondition string
|
GetDistrictsByCondition string
|
||||||
GetWardByCondition string
|
GetWardByCondition string
|
||||||
GetWardsByCondition string
|
GetWardsByCondition string
|
||||||
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"),
|
||||||
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),
|
GetDistrictsByCodes: getLocationValue("get_districts_by_codes"),
|
||||||
GetWardsByCodes: getLocationValue("get_wards_by_codes"),
|
GetWardsByCodes: getLocationValue("get_wards_by_codes"),
|
||||||
GetProvinceByCondition: getLocationValue("get_province_by_condition"),
|
GetProvinceByCondition: getLocationValue("get_province_by_condition"),
|
||||||
GetProvincesByCondition: getLocationValue("get_provinces_by_condition"),
|
GetProvincesByCondition: getLocationValue("get_provinces_by_condition"),
|
||||||
GetDistrictByCondition: getLocationValue("get_district_by_condition"),
|
GetDistrictByCondition: getLocationValue("get_district_by_condition"),
|
||||||
GetDistrictsByCondition: getLocationValue("get_districts_byCondition"),
|
GetDistrictsByCondition: getLocationValue("get_districts_byCondition"),
|
||||||
GetWardByCondition: getLocationValue("get_ward_by_condition"),
|
GetWardByCondition: getLocationValue("get_ward_by_condition"),
|
||||||
GetWardsByCondition: getLocationValue("get_wards_by_condition"),
|
GetWardsByCondition: getLocationValue("get_wards_by_condition"),
|
||||||
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"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue