From 0bed9a6dfbbad2d17daaedcdf87d78de82156e9e Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 27 Oct 2022 14:30:40 +0700 Subject: [PATCH 01/12] [location] refactor code --- client/location.go | 208 +++++++++++++++++++++++++++++++++++++ model/common_request.go | 16 +++ model/location_request.go | 76 +++++++++++--- model/location_response.go | 123 +++++++++++++++------- subject/location.go | 36 +++++-- 5 files changed, 399 insertions(+), 60 deletions(-) diff --git a/client/location.go b/client/location.go index 18be423..db19312 100644 --- a/client/location.go +++ b/client/location.go @@ -104,3 +104,211 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa return r.Data, nil } + +// GetProvinceByCondition ... +func (l Location) GetProvinceByCondition(p model.RequestCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetProvinceByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// GetProvincesByCondition ... +func (l Location) GetProvincesByCondition(p model.RequestCondition) ([]*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationProvinceDetailResponse `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 +} + +// GetDistrictByCondition ... +func (l Location) GetDistrictByCondition(p model.RequestCondition) (*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationDistrictDetailResponse `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 +} + +// GetDistrictsByCondition ... +func (l Location) GetDistrictsByCondition(p model.RequestCondition) ([]*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationDistrictDetailResponse `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 +} + +// GetWardByCondition ... +func (l Location) GetWardByCondition(p model.RequestCondition) (*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetWardByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationWardDetailResponse `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 +} + +// GetWardsByCondition ... +func (l Location) GetWardsByCondition(p model.RequestCondition) ([]*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationWardDetailResponse `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 +} + +// CountProvinceByCondition ... +func (l Location) CountProvinceByCondition(p model.RequestCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountDistrictByCondition ... +func (l Location) CountDistrictByCondition(p model.RequestCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountWardByCondition ... +func (l Location) CountWardByCondition(p model.RequestCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + 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 +} diff --git a/model/common_request.go b/model/common_request.go index 0ce5163..4ffd6e1 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -20,3 +20,19 @@ type ActionBy struct { ID string `json:"id"` Name string `json:"name"` } + +// RequestCondition ... +type RequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + + Keyword string `json:"keyword"` + Region string `json:"region"` +} diff --git a/model/location_request.go b/model/location_request.go index 4533db7..e4312ce 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -1,23 +1,65 @@ package model // LocationRequestPayload ... -type LocationRequestPayload struct { - Province int `json:"province"` - District int `json:"district"` - Ward int `json:"ward"` -} +type ( + LocationRequestPayload struct { + Province int `json:"province"` + District int `json:"district"` + Ward int `json:"ward"` + } -// ProvinceRequestPayload ... -type ProvinceRequestPayload struct { - Codes []int `json:"codes"` -} + // ProvinceRequestPayload ... + ProvinceRequestPayload struct { + Codes []int `json:"codes"` + } -// DistrictRequestPayload ... -type DistrictRequestPayload struct { - Codes []int `json:"codes"` -} + // ProvinceRequestCondition ... + ProvinceRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + Keyword string `json:"keyword"` + Region string `json:"region"` + } -// WardRequestPayload ... -type WardRequestPayload struct { - Codes []int `json:"codes"` -} + // DistrictRequestPayload ... + DistrictRequestPayload struct { + Codes []int `json:"codes"` + } + + // DistrictRequestCondition ... + DistrictRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + ProvinceCode int `json:"provinceCode"` + Slug string `json:"slug"` + ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` + } + + // WardRequestPayload ... + WardRequestPayload struct { + Codes []int `json:"codes"` + } + + // WardRequestCondition ... + WardRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + Slug string `json:"slug"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` + } + + // ProvinceDistinctWithField ... + ProvinceDistinctWithField struct { + Conditions struct { + Region string `json:"region"` + } `json:"conditions"` + Field string `json:"filed"` + } +) diff --git a/model/location_response.go b/model/location_response.go index 484d89e..1595908 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,43 +1,96 @@ package model -type ResponseLocationAddress struct { - Province LocationProvince `json:"province"` - District LocationDistrict `json:"district"` - Ward LocationWard `json:"ward"` -} +import "time" -// LocationProvince ... -type LocationProvince struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} +type ( + // ResponseLocationAddress ... + ResponseLocationAddress struct { + Province LocationProvince `json:"province"` + District LocationDistrict `json:"district"` + Ward LocationWard `json:"ward"` + } -// LocationDistrict ... -type LocationDistrict struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} + // LocationProvince ... + LocationProvince struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + } -// LocationWard ... -type LocationWard struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} + // LocationDistrict ... + LocationDistrict struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + } -// LocationProvinceResponse ... -type LocationProvinceResponse struct { - Provinces []LocationProvince `json:"provinces"` -} + // LocationWard ... + LocationWard struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + } -// LocationDistrictResponse ... -type LocationDistrictResponse struct { - Districts []LocationDistrict `json:"districts"` -} + // LocationProvinceResponse ... + LocationProvinceResponse struct { + Provinces []LocationProvince `json:"provinces"` + } -// LocationWardResponse ... -type LocationWardResponse struct { - Wards []LocationWard `json:"wards"` -} + // LocationDistrictResponse ... + LocationDistrictResponse struct { + Districts []LocationDistrict `json:"districts"` + } + + // LocationWardResponse ... + LocationWardResponse struct { + Wards []LocationWard `json:"wards"` + } + + // LocationProvinceDetailResponse ... + LocationProvinceDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` + Code int `json:"code"` + CountryCode string `json:"countryCode"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + TotalDistricts int `json:"totalDistricts"` + TotalWards int `json:"totalWards"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + // LocationDistrictDetailResponse ... + LocationDistrictDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` + Code int `json:"code"` + ProvinceCode int `json:"provinceCode"` + Area int `json:"area"` + TotalWards int `json:"totalWards"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + // LocationWardDetailResponse ... + LocationWardDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + OldSlugs []string `json:"oldSlugs"` + Code int `json:"code"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } +) diff --git a/subject/location.go b/subject/location.go index b19a59b..c625ca4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,13 +7,33 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + GetProvinceByCondition string + GetProvincesByCondition string + GetDistrictByCondition string + GetDistrictsByCondition string + GetWardByCondition string + GetWardsByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string + ProvinceDistinctWithField string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetProvinceByCondition: getLocationValue("get_province_by_condition"), + GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), + GetDistrictByCondition: getLocationValue("get_district_by_condition"), + GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), + GetWardByCondition: getLocationValue("get_ward_by_condition"), + GetWardsByCondition: getLocationValue("get_wards_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), + ProvinceDistinctWithField: getLocationValue("province_distinct_with_field"), } -- 2.34.1 From cb45dbb694526c498e0c853fd7ceb21e26ac9cd0 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 27 Oct 2022 16:03:11 +0700 Subject: [PATCH 02/12] [location] add slug to ResponseLocationAdress --- model/location_response.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/location_response.go b/model/location_response.go index 1595908..f0b4116 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -15,6 +15,7 @@ type ( ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` RegionCode string `json:"regionCode"` MainRegionCode string `json:"mainRegionCode"` } @@ -24,6 +25,7 @@ type ( ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` } // LocationWard ... @@ -31,6 +33,7 @@ type ( ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` } // LocationProvinceResponse ... @@ -53,7 +56,6 @@ type ( ID string `json:"_id"` Name string `json:"name"` SearchString string `json:"searchString"` - Slug string `json:"slug"` OldSlug string `json:"oldSlug"` Code int `json:"code"` CountryCode string `json:"countryCode"` @@ -70,7 +72,6 @@ type ( ID string `json:"_id"` Name string `json:"name"` SearchString string `json:"searchString"` - Slug string `json:"slug"` OldSlug string `json:"oldSlug"` Code int `json:"code"` ProvinceCode int `json:"provinceCode"` @@ -85,7 +86,6 @@ type ( ID string `json:"_id"` Name string `json:"name"` SearchString string `json:"searchString"` - Slug string `json:"slug"` OldSlugs []string `json:"oldSlugs"` Code int `json:"code"` DistrictCode int `json:"districtCode"` -- 2.34.1 From 006accb41597d6b9c74ad0c5136503a17a366acd Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Thu, 27 Oct 2022 16:29:38 +0700 Subject: [PATCH 03/12] [Update] Response warehouse --- model/warehouse_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index c667290..0b6cee0 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -119,6 +119,7 @@ type CommonLocation struct { ID string `json:"id"` Name string `json:"name"` Code int `json:"code"` + Slug string `json:"slug"` } // ResponseLatLng ... -- 2.34.1 From 34b1de6d4241dae7a57c6cb5d780a27910eb905e Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 7 Nov 2022 15:48:28 +0700 Subject: [PATCH 04/12] [location] update request model add page & limit --- model/common_request.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/common_request.go b/model/common_request.go index 4ffd6e1..8442864 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -35,4 +35,7 @@ type RequestCondition struct { Keyword string `json:"keyword"` Region string `json:"region"` + + Page int `json:"page"` + Limit int `json:"limit"` } -- 2.34.1 From d80b305b1adca5d67270d893c0453f1b1b84eca6 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 7 Nov 2022 16:04:12 +0700 Subject: [PATCH 05/12] [location] update request model page & limit --- model/common_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/common_request.go b/model/common_request.go index 8442864..ca13b4c 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -36,6 +36,6 @@ type RequestCondition struct { Keyword string `json:"keyword"` Region string `json:"region"` - Page int `json:"page"` - Limit int `json:"limit"` + Page int64 `json:"page"` + Limit int64 `json:"limit"` } -- 2.34.1 From f602e17ef28525ca7fa0ec83abf0461896c70329 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Thu, 17 Nov 2022 16:49:02 +0700 Subject: [PATCH 06/12] [location] add oldSlug to RequestCondition --- model/common_request.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/common_request.go b/model/common_request.go index ca13b4c..3568338 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -28,7 +28,9 @@ type RequestCondition struct { DistrictCode int `json:"districtCode"` ProvinceCode int `json:"provinceCode"` - Slug string `json:"slug"` + Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` + Slugs []string `json:"slugs"` DistrictSlug string `json:"districtSlug"` ProvinceSlug string `json:"provinceSlug"` -- 2.34.1 From b9885a2a0288acb99eaf2892a6bd2ce7fdb048fd Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Thu, 17 Nov 2022 17:19:04 +0700 Subject: [PATCH 07/12] [location] RequestCondition oldSlugs --- model/common_request.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/common_request.go b/model/common_request.go index 3568338..447ae57 100644 --- a/model/common_request.go +++ b/model/common_request.go @@ -31,9 +31,11 @@ type RequestCondition struct { Slug string `json:"slug"` OldSlug string `json:"oldSlug"` - Slugs []string `json:"slugs"` - DistrictSlug string `json:"districtSlug"` - ProvinceSlug string `json:"provinceSlug"` + Slugs []string `json:"slugs"` + OldSlugs []string `json:"oldSlugs"` + + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` Keyword string `json:"keyword"` Region string `json:"region"` -- 2.34.1 From be18b81589383d04850c6f34937ad857ab5150fa Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 00:08:21 +0700 Subject: [PATCH 08/12] [location] update location resp model --- model/location_response.go | 54 +++++++++++++++----------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/model/location_response.go b/model/location_response.go index f0b4116..3352a8f 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,7 +1,5 @@ package model -import "time" - type ( // ResponseLocationAddress ... ResponseLocationAddress struct { @@ -53,44 +51,34 @@ type ( // LocationProvinceDetailResponse ... LocationProvinceDetailResponse struct { - ID string `json:"_id"` - Name string `json:"name"` - SearchString string `json:"searchString"` - OldSlug string `json:"oldSlug"` - Code int `json:"code"` - CountryCode string `json:"countryCode"` - RegionCode string `json:"regionCode"` - MainRegionCode string `json:"mainRegionCode"` - TotalDistricts int `json:"totalDistricts"` - TotalWards int `json:"totalWards"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + Name string `json:"name"` + Slug string `json:"slug"` + Code int `json:"code"` + CountryCode string `json:"countryCode"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + TotalDistricts int `json:"totalDistricts"` + TotalWards int `json:"totalWards"` } // LocationDistrictDetailResponse ... LocationDistrictDetailResponse struct { - ID string `json:"_id"` - Name string `json:"name"` - SearchString string `json:"searchString"` - OldSlug string `json:"oldSlug"` - Code int `json:"code"` - ProvinceCode int `json:"provinceCode"` - Area int `json:"area"` - TotalWards int `json:"totalWards"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + Name string `json:"name"` + OldSlugs []string `json:"oldSlugs"` + Slug string `json:"slug"` + Code int `json:"code"` + ProvinceCode int `json:"provinceCode"` + Area int `json:"area"` + TotalWards int `json:"totalWards"` } // LocationWardDetailResponse ... LocationWardDetailResponse struct { - ID string `json:"_id"` - Name string `json:"name"` - SearchString string `json:"searchString"` - OldSlugs []string `json:"oldSlugs"` - Code int `json:"code"` - DistrictCode int `json:"districtCode"` - ProvinceCode int `json:"provinceCode"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + Name string `json:"name"` + OldSlugs []string `json:"oldSlugs"` + Slug string `json:"slug"` + Code int `json:"code"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` } ) -- 2.34.1 From 1a77ac3d8e2093dbfb6761ba3a024f520d86c2b1 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 00:29:18 +0700 Subject: [PATCH 09/12] [location] update location resp model --- model/location_response.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/location_response.go b/model/location_response.go index 3352a8f..e48bdce 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -51,6 +51,7 @@ type ( // LocationProvinceDetailResponse ... LocationProvinceDetailResponse struct { + ID string `json:"_id"` Name string `json:"name"` Slug string `json:"slug"` Code int `json:"code"` @@ -63,6 +64,7 @@ type ( // LocationDistrictDetailResponse ... LocationDistrictDetailResponse struct { + ID string `json:"_id"` Name string `json:"name"` OldSlugs []string `json:"oldSlugs"` Slug string `json:"slug"` @@ -74,6 +76,7 @@ type ( // LocationWardDetailResponse ... LocationWardDetailResponse struct { + ID string `json:"_id"` Name string `json:"name"` OldSlugs []string `json:"oldSlugs"` Slug string `json:"slug"` -- 2.34.1 From 8b907cec0d42722027128a0b196762bb2eccf490 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 15:59:56 +0700 Subject: [PATCH 10/12] new location subject --- subject/location.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subject/location.go b/subject/location.go index c625ca4..3ee9baf 100644 --- a/subject/location.go +++ b/subject/location.go @@ -8,9 +8,13 @@ func getLocationValue(val string) string { var Location = struct { GetLocationByCode string + GetLocationByCodeNew string GetProvincesByCodes string + GetProvincesByCodesNew string GetDistrictsByCodes string + GetDistrictsByCodesNew string GetWardsByCodes string + GetWardsByCodesNew string GetProvinceByCondition string GetProvincesByCondition string GetDistrictByCondition string @@ -23,9 +27,13 @@ var Location = struct { ProvinceDistinctWithField string }{ GetLocationByCode: getLocationValue("get_location_warehouse"), + GetLocationByCodeNew: getLocationValue("get_location_warehouse_new"), GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetProvincesByCodesNew: getLocationValue("get_provinces_by_codes_new"), GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetDistrictsByCodesNew: getLocationValue("get_districts_by_codes_new"), GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetWardsByCodesNew: getLocationValue("get_wards_by_codes_new"), GetProvinceByCondition: getLocationValue("get_province_by_condition"), GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), GetDistrictByCondition: getLocationValue("get_district_by_condition"), -- 2.34.1 From e3599d1903f0f94885cda7b14d5ef485ee50d381 Mon Sep 17 00:00:00 2001 From: thaingocquang Date: Mon, 21 Nov 2022 16:20:06 +0700 Subject: [PATCH 11/12] [location] update location subject --- client/location.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/location.go b/client/location.go index db19312..803e33d 100644 --- a/client/location.go +++ b/client/location.go @@ -19,7 +19,7 @@ func GetLocation() Location { // GetLocationByCode ... func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*model.ResponseLocationAddress, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCode, toBytes(payload)) + msg, err := natsio.GetServer().Request(subject.Location.GetLocationByCodeNew, toBytes(payload)) if err != nil { return nil, err } @@ -40,7 +40,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode // GetProvincesByCodes ... ... func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodesNew, toBytes(p)) if err != nil { return nil, err } @@ -62,7 +62,7 @@ func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.Lo // GetDistrictsByCodes ... func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.LocationDistrictResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodes, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCodesNew, toBytes(p)) if err != nil { return nil, err } @@ -84,7 +84,7 @@ func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.Lo // GetWardsByCodes ... func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWardResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodes, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCodesNew, toBytes(p)) if err != nil { return nil, err } -- 2.34.1 From f69ac3ba0cd7379baf428cc085ecb5bf80415819 Mon Sep 17 00:00:00 2001 From: quang Date: Mon, 16 Jan 2023 14:03:09 +0700 Subject: [PATCH 12/12] test --- model/location_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/location_request.go b/model/location_request.go index e4312ce..47ddd01 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -2,6 +2,7 @@ package model // LocationRequestPayload ... type ( + // LocationRequestPayload ... LocationRequestPayload struct { Province int `json:"province"` District int `json:"district"` -- 2.34.1