国家/地区、省份等相关表增加真实ID字段,防止数据表被用户修改时无法对应

This commit is contained in:
刘祥超
2023-07-07 09:52:46 +08:00
parent a38dd1cef8
commit 8efaacf1ef
22 changed files with 13071 additions and 6183 deletions

View File

@@ -339,7 +339,7 @@ func (this *IPLibraryFileDAO) GenerateIPLibrary(tx *dbs.Tx, libraryFileId int64)
var countries = []*iplibrary.Country{} var countries = []*iplibrary.Country{}
for _, country := range dbCountries { for _, country := range dbCountries {
countries = append(countries, &iplibrary.Country{ countries = append(countries, &iplibrary.Country{
Id: types.Uint16(country.Id), Id: types.Uint16(country.ValueId),
Name: country.DisplayName(), Name: country.DisplayName(),
Codes: country.AllCodes(), Codes: country.AllCodes(),
}) })
@@ -354,7 +354,7 @@ func (this *IPLibraryFileDAO) GenerateIPLibrary(tx *dbs.Tx, libraryFileId int64)
var provinces = []*iplibrary.Province{} var provinces = []*iplibrary.Province{}
for _, province := range dbProvinces { for _, province := range dbProvinces {
provinces = append(provinces, &iplibrary.Province{ provinces = append(provinces, &iplibrary.Province{
Id: types.Uint16(province.Id), Id: types.Uint16(province.ValueId),
Name: province.DisplayName(), Name: province.DisplayName(),
Codes: province.AllCodes(), Codes: province.AllCodes(),
}) })
@@ -369,7 +369,7 @@ func (this *IPLibraryFileDAO) GenerateIPLibrary(tx *dbs.Tx, libraryFileId int64)
var cities = []*iplibrary.City{} var cities = []*iplibrary.City{}
for _, city := range dbCities { for _, city := range dbCities {
cities = append(cities, &iplibrary.City{ cities = append(cities, &iplibrary.City{
Id: city.Id, Id: city.ValueId,
Name: city.DisplayName(), Name: city.DisplayName(),
Codes: city.AllCodes(), Codes: city.AllCodes(),
}) })
@@ -384,7 +384,7 @@ func (this *IPLibraryFileDAO) GenerateIPLibrary(tx *dbs.Tx, libraryFileId int64)
var towns = []*iplibrary.Town{} var towns = []*iplibrary.Town{}
for _, town := range dbTowns { for _, town := range dbTowns {
towns = append(towns, &iplibrary.Town{ towns = append(towns, &iplibrary.Town{
Id: town.Id, Id: town.ValueId,
Name: town.DisplayName(), Name: town.DisplayName(),
Codes: town.AllCodes(), Codes: town.AllCodes(),
}) })
@@ -399,7 +399,7 @@ func (this *IPLibraryFileDAO) GenerateIPLibrary(tx *dbs.Tx, libraryFileId int64)
var providers = []*iplibrary.Provider{} var providers = []*iplibrary.Provider{}
for _, provider := range dbProviders { for _, provider := range dbProviders {
providers = append(providers, &iplibrary.Provider{ providers = append(providers, &iplibrary.Provider{
Id: types.Uint16(provider.Id), Id: types.Uint16(provider.ValueId),
Name: provider.DisplayName(), Name: provider.DisplayName(),
Codes: provider.AllCodes(), Codes: provider.AllCodes(),
}) })
@@ -440,35 +440,35 @@ func (this *IPLibraryFileDAO) GenerateIPLibrary(tx *dbs.Tx, libraryFileId int64)
var countryMap = map[string]int64{} // countryName => countryId var countryMap = map[string]int64{} // countryName => countryId
for _, country := range dbCountries { for _, country := range dbCountries {
for _, code := range country.AllCodes() { for _, code := range country.AllCodes() {
countryMap[code] = int64(country.Id) countryMap[code] = int64(country.ValueId)
} }
} }
var provinceMap = map[string]int64{} // countryId_provinceName => provinceId var provinceMap = map[string]int64{} // countryId_provinceName => provinceId
for _, province := range dbProvinces { for _, province := range dbProvinces {
for _, code := range province.AllCodes() { for _, code := range province.AllCodes() {
provinceMap[types.String(province.CountryId)+"_"+code] = int64(province.Id) provinceMap[types.String(province.CountryId)+"_"+code] = int64(province.ValueId)
} }
} }
var cityMap = map[string]int64{} // provinceId_cityName => cityId var cityMap = map[string]int64{} // provinceId_cityName => cityId
for _, city := range dbCities { for _, city := range dbCities {
for _, code := range city.AllCodes() { for _, code := range city.AllCodes() {
cityMap[types.String(city.ProvinceId)+"_"+code] = int64(city.Id) cityMap[types.String(city.ProvinceId)+"_"+code] = int64(city.ValueId)
} }
} }
var townMap = map[string]int64{} // cityId_townName => townId var townMap = map[string]int64{} // cityId_townName => townId
for _, town := range dbTowns { for _, town := range dbTowns {
for _, code := range town.AllCodes() { for _, code := range town.AllCodes() {
townMap[types.String(town.CityId)+"_"+code] = int64(town.Id) townMap[types.String(town.CityId)+"_"+code] = int64(town.ValueId)
} }
} }
var providerMap = map[string]int64{} // providerName => providerId var providerMap = map[string]int64{} // providerName => providerId
for _, provider := range dbProviders { for _, provider := range dbProviders {
for _, code := range provider.AllCodes() { for _, code := range provider.AllCodes() {
providerMap[code] = int64(provider.Id) providerMap[code] = int64(provider.ValueId)
} }
} }

View File

@@ -42,7 +42,7 @@ func init() {
// EnableRegionCity 启用条目 // EnableRegionCity 启用条目
func (this *RegionCityDAO) EnableRegionCity(tx *dbs.Tx, id uint32) error { func (this *RegionCityDAO) EnableRegionCity(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionCityStateEnabled). Set("state", RegionCityStateEnabled).
Update() Update()
return err return err
@@ -51,7 +51,7 @@ func (this *RegionCityDAO) EnableRegionCity(tx *dbs.Tx, id uint32) error {
// DisableRegionCity 禁用条目 // DisableRegionCity 禁用条目
func (this *RegionCityDAO) DisableRegionCity(tx *dbs.Tx, id uint32) error { func (this *RegionCityDAO) DisableRegionCity(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionCityStateDisabled). Set("state", RegionCityStateDisabled).
Update() Update()
return err return err
@@ -60,7 +60,7 @@ func (this *RegionCityDAO) DisableRegionCity(tx *dbs.Tx, id uint32) error {
// FindEnabledRegionCity 查找启用中的条目 // FindEnabledRegionCity 查找启用中的条目
func (this *RegionCityDAO) FindEnabledRegionCity(tx *dbs.Tx, id int64) (*RegionCity, error) { func (this *RegionCityDAO) FindEnabledRegionCity(tx *dbs.Tx, id int64) (*RegionCity, error) {
result, err := this.Query(tx). result, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Attr("state", RegionCityStateEnabled). Attr("state", RegionCityStateEnabled).
Find() Find()
if result == nil { if result == nil {
@@ -72,7 +72,7 @@ func (this *RegionCityDAO) FindEnabledRegionCity(tx *dbs.Tx, id int64) (*RegionC
// FindRegionCityName 根据主键查找名称 // FindRegionCityName 根据主键查找名称
func (this *RegionCityDAO) FindRegionCityName(tx *dbs.Tx, id uint32) (string, error) { func (this *RegionCityDAO) FindRegionCityName(tx *dbs.Tx, id uint32) (string, error) {
return this.Query(tx). return this.Query(tx).
Pk(id). Attr("valueId", id).
Result("name"). Result("name").
FindStringCol("") FindStringCol("")
} }
@@ -81,7 +81,7 @@ func (this *RegionCityDAO) FindRegionCityName(tx *dbs.Tx, id uint32) (string, er
func (this *RegionCityDAO) FindCityWithDataId(tx *dbs.Tx, dataId string) (int64, error) { func (this *RegionCityDAO) FindCityWithDataId(tx *dbs.Tx, dataId string) (int64, error) {
return this.Query(tx). return this.Query(tx).
Attr("dataId", dataId). Attr("dataId", dataId).
ResultPk(). Result(RegionCityField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -93,7 +93,7 @@ func (this *RegionCityDAO) CreateCity(tx *dbs.Tx, provinceId int64, name string,
op.DataId = dataId op.DataId = dataId
op.State = RegionCityStateEnabled op.State = RegionCityStateEnabled
codes := []string{name} var codes = []string{name}
codesJSON, err := json.Marshal(codes) codesJSON, err := json.Marshal(codes)
if err != nil { if err != nil {
return 0, err return 0, err
@@ -103,7 +103,18 @@ func (this *RegionCityDAO) CreateCity(tx *dbs.Tx, provinceId int64, name string,
if err != nil { if err != nil {
return 0, err return 0, err
} }
return types.Int64(op.Id), nil var cityId = types.Int64(op.Id)
// value id
err = this.Query(tx).
Pk(cityId).
Set(RegionCityField_ValueId, cityId).
UpdateQuickly()
if err != nil {
return 0, err
}
return cityId, nil
} }
// FindCityIdWithName 根据城市名查找城市ID // FindCityIdWithName 根据城市名查找城市ID
@@ -113,7 +124,7 @@ func (this *RegionCityDAO) FindCityIdWithName(tx *dbs.Tx, provinceId int64, city
Where("(name=:cityName OR customName=:cityName OR JSON_CONTAINS(codes, :cityNameJSON) OR JSON_CONTAINS(customCodes, :cityNameJSON))"). Where("(name=:cityName OR customName=:cityName OR JSON_CONTAINS(codes, :cityNameJSON) OR JSON_CONTAINS(customCodes, :cityNameJSON))").
Param("cityName", cityName). Param("cityName", cityName).
Param("cityNameJSON", strconv.Quote(cityName)). // 查询的需要是个JSON字符串所以这里加双引号 Param("cityNameJSON", strconv.Quote(cityName)). // 查询的需要是个JSON字符串所以这里加双引号
ResultPk(). Result(RegionCityField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -147,7 +158,7 @@ func (this *RegionCityDAO) UpdateCityCustom(tx *dbs.Tx, cityId int64, customName
} }
return this.Query(tx). return this.Query(tx).
Pk(cityId). Attr(RegionCityField_ValueId, cityId).
Set("customName", customName). Set("customName", customName).
Set("customCodes", customCodesJSON). Set("customCodes", customCodesJSON).
UpdateQuickly() UpdateQuickly()

View File

@@ -2,9 +2,22 @@ package regions
import "github.com/iwind/TeaGo/dbs" import "github.com/iwind/TeaGo/dbs"
const (
RegionCityField_Id dbs.FieldName = "id" // ID
RegionCityField_ValueId dbs.FieldName = "valueId" // 实际ID
RegionCityField_ProvinceId dbs.FieldName = "provinceId" // 省份ID
RegionCityField_Name dbs.FieldName = "name" // 名称
RegionCityField_Codes dbs.FieldName = "codes" // 代号
RegionCityField_CustomName dbs.FieldName = "customName" // 自定义名称
RegionCityField_CustomCodes dbs.FieldName = "customCodes" // 自定义代号
RegionCityField_State dbs.FieldName = "state" // 状态
RegionCityField_DataId dbs.FieldName = "dataId" // 原始数据ID
)
// RegionCity 区域-城市 // RegionCity 区域-城市
type RegionCity struct { type RegionCity struct {
Id uint32 `field:"id"` // ID Id1 uint32 `field:"id"` // ID
ValueId uint32 `field:"valueId"` // 实际ID
ProvinceId uint32 `field:"provinceId"` // 省份ID ProvinceId uint32 `field:"provinceId"` // 省份ID
Name string `field:"name"` // 名称 Name string `field:"name"` // 名称
Codes dbs.JSON `field:"codes"` // 代号 Codes dbs.JSON `field:"codes"` // 代号
@@ -15,14 +28,15 @@ type RegionCity struct {
} }
type RegionCityOperator struct { type RegionCityOperator struct {
Id interface{} // ID Id any // ID
ProvinceId interface{} // 省份ID ValueId any // 实际ID
Name interface{} // 名称 ProvinceId any // 省份ID
Codes interface{} // 代号 Name any // 名称
CustomName interface{} // 自定义名称 Codes any // 代号
CustomCodes interface{} // 自定义代号 CustomName any // 自定义名称
State interface{} // 状态 CustomCodes any // 自定义代号
DataId interface{} // 原始数据ID State any // 状态
DataId any // 原始数据ID
} }
func NewRegionCityOperator() *RegionCityOperator { func NewRegionCityOperator() *RegionCityOperator {

View File

@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/regionconfigs"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/dbs"
@@ -20,10 +21,6 @@ const (
RegionCountryStateDisabled = 0 // 已禁用 RegionCountryStateDisabled = 0 // 已禁用
) )
const (
CountryChinaId = 1
)
var regionCountryIdAndNameCacheMap = map[int64]string{} // country id => name var regionCountryIdAndNameCacheMap = map[int64]string{} // country id => name
type RegionCountryDAO dbs.DAO type RegionCountryDAO dbs.DAO
@@ -50,7 +47,7 @@ func init() {
// EnableRegionCountry 启用条目 // EnableRegionCountry 启用条目
func (this *RegionCountryDAO) EnableRegionCountry(tx *dbs.Tx, id uint32) error { func (this *RegionCountryDAO) EnableRegionCountry(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionCountryStateEnabled). Set("state", RegionCountryStateEnabled).
Update() Update()
return err return err
@@ -59,7 +56,7 @@ func (this *RegionCountryDAO) EnableRegionCountry(tx *dbs.Tx, id uint32) error {
// DisableRegionCountry 禁用条目 // DisableRegionCountry 禁用条目
func (this *RegionCountryDAO) DisableRegionCountry(tx *dbs.Tx, id int64) error { func (this *RegionCountryDAO) DisableRegionCountry(tx *dbs.Tx, id int64) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionCountryStateDisabled). Set("state", RegionCountryStateDisabled).
Update() Update()
return err return err
@@ -68,7 +65,7 @@ func (this *RegionCountryDAO) DisableRegionCountry(tx *dbs.Tx, id int64) error {
// FindEnabledRegionCountry 查找启用中的条目 // FindEnabledRegionCountry 查找启用中的条目
func (this *RegionCountryDAO) FindEnabledRegionCountry(tx *dbs.Tx, id int64) (*RegionCountry, error) { func (this *RegionCountryDAO) FindEnabledRegionCountry(tx *dbs.Tx, id int64) (*RegionCountry, error) {
result, err := this.Query(tx). result, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Attr("state", RegionCountryStateEnabled). Attr("state", RegionCountryStateEnabled).
Find() Find()
if result == nil { if result == nil {
@@ -88,7 +85,7 @@ func (this *RegionCountryDAO) FindRegionCountryName(tx *dbs.Tx, id int64) (strin
} }
name, err := this.Query(tx). name, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Result("name"). Result("name").
FindStringCol("") FindStringCol("")
if err != nil { if err != nil {
@@ -105,7 +102,7 @@ func (this *RegionCountryDAO) FindRegionCountryName(tx *dbs.Tx, id int64) (strin
func (this *RegionCountryDAO) FindCountryIdWithDataId(tx *dbs.Tx, dataId string) (int64, error) { func (this *RegionCountryDAO) FindCountryIdWithDataId(tx *dbs.Tx, dataId string) (int64, error) {
return this.Query(tx). return this.Query(tx).
Attr("dataId", dataId). Attr("dataId", dataId).
ResultPk(). Result(RegionCountryField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -115,7 +112,7 @@ func (this *RegionCountryDAO) FindCountryIdWithName(tx *dbs.Tx, countryName stri
Where("(name=:countryName OR JSON_CONTAINS(codes, :countryNameJSON) OR customName=:countryName OR JSON_CONTAINS(customCodes, :countryNameJSON))"). Where("(name=:countryName OR JSON_CONTAINS(codes, :countryNameJSON) OR customName=:countryName OR JSON_CONTAINS(customCodes, :countryNameJSON))").
Param("countryName", countryName). Param("countryName", countryName).
Param("countryNameJSON", strconv.Quote(countryName)). // 查询的需要是个JSON字符串所以这里加双引号 Param("countryNameJSON", strconv.Quote(countryName)). // 查询的需要是个JSON字符串所以这里加双引号
ResultPk(). Result(RegionCountryField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -145,16 +142,61 @@ func (this *RegionCountryDAO) CreateCountry(tx *dbs.Tx, name string, dataId stri
if err != nil { if err != nil {
return 0, err return 0, err
} }
return types.Int64(op.Id), nil var countryId = types.Int64(op.Id)
err = this.Query(tx).
Pk(countryId).
Set(RegionCountryField_ValueId, countryId).
UpdateQuickly()
if err != nil {
return 0, err
}
return countryId, nil
} }
// FindAllEnabledCountriesOrderByPinyin 查找所有可用的国家并按拼音排序 // FindAllEnabledCountriesOrderByPinyin 查找所有可用的国家并按拼音排序
func (this *RegionCountryDAO) FindAllEnabledCountriesOrderByPinyin(tx *dbs.Tx) (result []*RegionCountry, err error) { func (this *RegionCountryDAO) FindAllEnabledCountriesOrderByPinyin(tx *dbs.Tx) (result []*RegionCountry, err error) {
_, err = this.Query(tx). ones, err := this.Query(tx).
State(RegionCountryStateEnabled). State(RegionCountryStateEnabled).
Slice(&result). Asc("JSON_EXTRACT(pinyin, '$[0]')").
Asc("pinyin").
FindAll() FindAll()
if err != nil {
return nil, err
}
// resort China special regions
var chinaRegionMap = map[int64]*RegionCountry{} // countryId => *RegionCountry
for _, one := range ones {
var country = one.(*RegionCountry)
var valueId = int64(country.ValueId)
if regionconfigs.CheckRegionIsInGreaterChina(valueId) {
chinaRegionMap[valueId] = country
}
}
for _, one := range ones {
var country = one.(*RegionCountry)
var valueId = int64(country.ValueId)
if valueId == regionconfigs.RegionChinaId {
result = append(result, country)
// add hk, tw, mo, mainland ...
for _, subRegionId := range regionconfigs.FindAllGreaterChinaSubRegionIds() {
subRegion, ok := chinaRegionMap[subRegionId]
if ok {
result = append(result, subRegion)
}
}
continue
}
if regionconfigs.CheckRegionIsInGreaterChina(valueId) {
continue
}
result = append(result, country)
}
return return
} }
@@ -163,7 +205,7 @@ func (this *RegionCountryDAO) FindAllCountries(tx *dbs.Tx) (result []*RegionCoun
_, err = this.Query(tx). _, err = this.Query(tx).
State(RegionCountryStateEnabled). State(RegionCountryStateEnabled).
Slice(&result). Slice(&result).
AscPk(). Asc(RegionCountryField_ValueId).
FindAll() FindAll()
return return
} }
@@ -185,7 +227,7 @@ func (this *RegionCountryDAO) UpdateCountryCustom(tx *dbs.Tx, countryId int64, c
}() }()
return this.Query(tx). return this.Query(tx).
Pk(countryId). Attr("valueId", countryId).
Set("customName", customName). Set("customName", customName).
Set("customCodes", customCodesJSON). Set("customCodes", customCodesJSON).
UpdateQuickly() UpdateQuickly()

View File

@@ -2,9 +2,25 @@ package regions
import "github.com/iwind/TeaGo/dbs" import "github.com/iwind/TeaGo/dbs"
const (
RegionCountryField_Id dbs.FieldName = "id" // ID
RegionCountryField_ValueId dbs.FieldName = "valueId" // 实际ID
RegionCountryField_ValueCode dbs.FieldName = "valueCode" // 值代号
RegionCountryField_Name dbs.FieldName = "name" // 名称
RegionCountryField_Codes dbs.FieldName = "codes" // 代号
RegionCountryField_CustomName dbs.FieldName = "customName" // 自定义名称
RegionCountryField_CustomCodes dbs.FieldName = "customCodes" // 自定义代号
RegionCountryField_State dbs.FieldName = "state" // 状态
RegionCountryField_DataId dbs.FieldName = "dataId" // 原始数据ID
RegionCountryField_Pinyin dbs.FieldName = "pinyin" // 拼音
RegionCountryField_IsCommon dbs.FieldName = "isCommon" // 是否常用
)
// RegionCountry 区域-国家/地区 // RegionCountry 区域-国家/地区
type RegionCountry struct { type RegionCountry struct {
Id uint32 `field:"id"` // ID Id1 uint32 `field:"id"` // ID
ValueId uint32 `field:"valueId"` // 实际ID
ValueCode string `field:"valueCode"` // 值代号
Name string `field:"name"` // 名称 Name string `field:"name"` // 名称
Codes dbs.JSON `field:"codes"` // 代号 Codes dbs.JSON `field:"codes"` // 代号
CustomName string `field:"customName"` // 自定义名称 CustomName string `field:"customName"` // 自定义名称
@@ -12,17 +28,21 @@ type RegionCountry struct {
State uint8 `field:"state"` // 状态 State uint8 `field:"state"` // 状态
DataId string `field:"dataId"` // 原始数据ID DataId string `field:"dataId"` // 原始数据ID
Pinyin dbs.JSON `field:"pinyin"` // 拼音 Pinyin dbs.JSON `field:"pinyin"` // 拼音
IsCommon bool `field:"isCommon"` // 是否常用
} }
type RegionCountryOperator struct { type RegionCountryOperator struct {
Id interface{} // ID Id any // ID
Name interface{} // 名称 ValueId any // 实际ID
Codes interface{} // 代号 ValueCode any // 代号
CustomName interface{} // 自定义名称 Name any // 名称
CustomCodes interface{} // 自定义代号 Codes any // 代号
State interface{} // 状态 CustomName any // 自定义名称
DataId interface{} // 原始数据ID CustomCodes any // 自定义代号
Pinyin interface{} // 拼音 State any // 状态
DataId any // 原始数据ID
Pinyin any // 拼音
IsCommon any // 是否常用
} }
func NewRegionCountryOperator() *RegionCountryOperator { func NewRegionCountryOperator() *RegionCountryOperator {

View File

@@ -41,7 +41,7 @@ func init() {
// EnableRegionProvider 启用条目 // EnableRegionProvider 启用条目
func (this *RegionProviderDAO) EnableRegionProvider(tx *dbs.Tx, id uint32) error { func (this *RegionProviderDAO) EnableRegionProvider(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionProviderStateEnabled). Set("state", RegionProviderStateEnabled).
Update() Update()
return err return err
@@ -50,7 +50,7 @@ func (this *RegionProviderDAO) EnableRegionProvider(tx *dbs.Tx, id uint32) error
// DisableRegionProvider 禁用条目 // DisableRegionProvider 禁用条目
func (this *RegionProviderDAO) DisableRegionProvider(tx *dbs.Tx, id uint32) error { func (this *RegionProviderDAO) DisableRegionProvider(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionProviderStateDisabled). Set("state", RegionProviderStateDisabled).
Update() Update()
return err return err
@@ -59,7 +59,7 @@ func (this *RegionProviderDAO) DisableRegionProvider(tx *dbs.Tx, id uint32) erro
// FindEnabledRegionProvider 查找启用中的条目 // FindEnabledRegionProvider 查找启用中的条目
func (this *RegionProviderDAO) FindEnabledRegionProvider(tx *dbs.Tx, id int64) (*RegionProvider, error) { func (this *RegionProviderDAO) FindEnabledRegionProvider(tx *dbs.Tx, id int64) (*RegionProvider, error) {
result, err := this.Query(tx). result, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Attr("state", RegionProviderStateEnabled). Attr("state", RegionProviderStateEnabled).
Find() Find()
if result == nil { if result == nil {
@@ -71,7 +71,7 @@ func (this *RegionProviderDAO) FindEnabledRegionProvider(tx *dbs.Tx, id int64) (
// FindRegionProviderName 根据主键查找名称 // FindRegionProviderName 根据主键查找名称
func (this *RegionProviderDAO) FindRegionProviderName(tx *dbs.Tx, id uint32) (string, error) { func (this *RegionProviderDAO) FindRegionProviderName(tx *dbs.Tx, id uint32) (string, error) {
return this.Query(tx). return this.Query(tx).
Pk(id). Attr("valueId", id).
Result("name"). Result("name").
FindStringCol("") FindStringCol("")
} }
@@ -82,7 +82,7 @@ func (this *RegionProviderDAO) FindProviderIdWithName(tx *dbs.Tx, providerName s
Where("(name=:providerName OR customName=:providerName OR JSON_CONTAINS(codes, :providerNameJSON) OR JSON_CONTAINS(customCodes, :providerNameJSON))"). Where("(name=:providerName OR customName=:providerName OR JSON_CONTAINS(codes, :providerNameJSON) OR JSON_CONTAINS(customCodes, :providerNameJSON))").
Param("providerName", providerName). Param("providerName", providerName).
Param("providerNameJSON", strconv.Quote(providerName)). // 查询的需要是个JSON字符串所以这里加双引号 Param("providerNameJSON", strconv.Quote(providerName)). // 查询的需要是个JSON字符串所以这里加双引号
ResultPk(). Result(RegionProviderField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -96,7 +96,20 @@ func (this *RegionProviderDAO) CreateProvider(tx *dbs.Tx, name string) (int64, e
return 0, err return 0, err
} }
op.Codes = codesJSON op.Codes = codesJSON
return this.SaveInt64(tx, op) providerId, err := this.SaveInt64(tx, op)
if err != nil {
return 0, err
}
err = this.Query(tx).
Pk(providerId).
Set(RegionProviderField_ValueId, providerId).
UpdateQuickly()
if err != nil {
return 0, err
}
return providerId, nil
} }
// FindAllEnabledProviders 查找所有服务商 // FindAllEnabledProviders 查找所有服务商
@@ -119,7 +132,7 @@ func (this *RegionProviderDAO) UpdateProviderCustom(tx *dbs.Tx, providerId int64
} }
return this.Query(tx). return this.Query(tx).
Pk(providerId). Attr("valueId", providerId).
Set("customName", customName). Set("customName", customName).
Set("customCodes", customCodesJSON). Set("customCodes", customCodesJSON).
UpdateQuickly() UpdateQuickly()

View File

@@ -2,9 +2,20 @@ package regions
import "github.com/iwind/TeaGo/dbs" import "github.com/iwind/TeaGo/dbs"
const (
RegionProviderField_Id dbs.FieldName = "id" // ID
RegionProviderField_ValueId dbs.FieldName = "valueId" // 实际ID
RegionProviderField_Name dbs.FieldName = "name" // 名称
RegionProviderField_Codes dbs.FieldName = "codes" // 代号
RegionProviderField_CustomName dbs.FieldName = "customName" // 自定义名称
RegionProviderField_CustomCodes dbs.FieldName = "customCodes" // 自定义代号
RegionProviderField_State dbs.FieldName = "state" // 状态
)
// RegionProvider 区域-运营商 // RegionProvider 区域-运营商
type RegionProvider struct { type RegionProvider struct {
Id uint32 `field:"id"` // ID Id1 uint32 `field:"id"` // ID
ValueId uint32 `field:"valueId"` // 实际ID
Name string `field:"name"` // 名称 Name string `field:"name"` // 名称
Codes dbs.JSON `field:"codes"` // 代号 Codes dbs.JSON `field:"codes"` // 代号
CustomName string `field:"customName"` // 自定义名称 CustomName string `field:"customName"` // 自定义名称
@@ -13,12 +24,13 @@ type RegionProvider struct {
} }
type RegionProviderOperator struct { type RegionProviderOperator struct {
Id interface{} // ID Id any // ID
Name interface{} // 名称 ValueId any // 实际ID
Codes interface{} // 代号 Name any // 名称
CustomName interface{} // 自定义名称 Codes any // 代号
CustomCodes interface{} // 自定义代号 CustomName any // 自定义名称
State interface{} // 状态 CustomCodes any // 自定义代号
State any // 状态
} }
func NewRegionProviderOperator() *RegionProviderOperator { func NewRegionProviderOperator() *RegionProviderOperator {

View File

@@ -42,7 +42,7 @@ func init() {
// EnableRegionProvince 启用条目 // EnableRegionProvince 启用条目
func (this *RegionProvinceDAO) EnableRegionProvince(tx *dbs.Tx, id int64) error { func (this *RegionProvinceDAO) EnableRegionProvince(tx *dbs.Tx, id int64) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionProvinceStateEnabled). Set("state", RegionProvinceStateEnabled).
Update() Update()
return err return err
@@ -51,7 +51,7 @@ func (this *RegionProvinceDAO) EnableRegionProvince(tx *dbs.Tx, id int64) error
// DisableRegionProvince 禁用条目 // DisableRegionProvince 禁用条目
func (this *RegionProvinceDAO) DisableRegionProvince(tx *dbs.Tx, id int64) error { func (this *RegionProvinceDAO) DisableRegionProvince(tx *dbs.Tx, id int64) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionProvinceStateDisabled). Set("state", RegionProvinceStateDisabled).
Update() Update()
return err return err
@@ -60,7 +60,7 @@ func (this *RegionProvinceDAO) DisableRegionProvince(tx *dbs.Tx, id int64) error
// FindEnabledRegionProvince 查找启用中的条目 // FindEnabledRegionProvince 查找启用中的条目
func (this *RegionProvinceDAO) FindEnabledRegionProvince(tx *dbs.Tx, id int64) (*RegionProvince, error) { func (this *RegionProvinceDAO) FindEnabledRegionProvince(tx *dbs.Tx, id int64) (*RegionProvince, error) {
result, err := this.Query(tx). result, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Attr("state", RegionProvinceStateEnabled). Attr("state", RegionProvinceStateEnabled).
Find() Find()
if result == nil { if result == nil {
@@ -72,7 +72,7 @@ func (this *RegionProvinceDAO) FindEnabledRegionProvince(tx *dbs.Tx, id int64) (
// FindRegionProvinceName 根据主键查找名称 // FindRegionProvinceName 根据主键查找名称
func (this *RegionProvinceDAO) FindRegionProvinceName(tx *dbs.Tx, id int64) (string, error) { func (this *RegionProvinceDAO) FindRegionProvinceName(tx *dbs.Tx, id int64) (string, error) {
return this.Query(tx). return this.Query(tx).
Pk(id). Attr("valueId", id).
Result("name"). Result("name").
FindStringCol("") FindStringCol("")
} }
@@ -81,7 +81,7 @@ func (this *RegionProvinceDAO) FindRegionProvinceName(tx *dbs.Tx, id int64) (str
func (this *RegionProvinceDAO) FindProvinceIdWithDataId(tx *dbs.Tx, dataId string) (int64, error) { func (this *RegionProvinceDAO) FindProvinceIdWithDataId(tx *dbs.Tx, dataId string) (int64, error) {
return this.Query(tx). return this.Query(tx).
Attr("dataId", dataId). Attr("dataId", dataId).
ResultPk(). Result(RegionProvinceField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -92,7 +92,7 @@ func (this *RegionProvinceDAO) FindProvinceIdWithName(tx *dbs.Tx, countryId int6
Where("(name=:provinceName OR customName=:provinceName OR JSON_CONTAINS(codes, :provinceNameJSON) OR JSON_CONTAINS(customCodes, :provinceNameJSON))"). Where("(name=:provinceName OR customName=:provinceName OR JSON_CONTAINS(codes, :provinceNameJSON) OR JSON_CONTAINS(customCodes, :provinceNameJSON))").
Param("provinceName", provinceName). Param("provinceName", provinceName).
Param("provinceNameJSON", strconv.Quote(provinceName)). // 查询的需要是个JSON字符串所以这里加双引号 Param("provinceNameJSON", strconv.Quote(provinceName)). // 查询的需要是个JSON字符串所以这里加双引号
ResultPk(). Result(RegionProvinceField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
@@ -104,7 +104,7 @@ func (this *RegionProvinceDAO) CreateProvince(tx *dbs.Tx, countryId int64, name
op.DataId = dataId op.DataId = dataId
op.State = RegionProvinceStateEnabled op.State = RegionProvinceStateEnabled
codes := []string{name} var codes = []string{name}
codesJSON, err := json.Marshal(codes) codesJSON, err := json.Marshal(codes)
if err != nil { if err != nil {
return 0, err return 0, err
@@ -114,7 +114,17 @@ func (this *RegionProvinceDAO) CreateProvince(tx *dbs.Tx, countryId int64, name
if err != nil { if err != nil {
return 0, err return 0, err
} }
return types.Int64(op.Id), nil var provinceId = types.Int64(op.Id)
err = this.Query(tx).
Pk(provinceId).
Set(RegionProvinceField_ValueId, provinceId).
UpdateQuickly()
if err != nil {
return 0, err
}
return provinceId, nil
} }
// FindAllEnabledProvincesWithCountryId 查找某个国家/地区的所有省份 // FindAllEnabledProvincesWithCountryId 查找某个国家/地区的所有省份
@@ -122,7 +132,7 @@ func (this *RegionProvinceDAO) FindAllEnabledProvincesWithCountryId(tx *dbs.Tx,
_, err = this.Query(tx). _, err = this.Query(tx).
State(RegionProvinceStateEnabled). State(RegionProvinceStateEnabled).
Attr("countryId", countryId). Attr("countryId", countryId).
AscPk(). Asc(RegionProvinceField_ValueId).
Slice(&result). Slice(&result).
FindAll() FindAll()
return return
@@ -132,7 +142,7 @@ func (this *RegionProvinceDAO) FindAllEnabledProvincesWithCountryId(tx *dbs.Tx,
func (this *RegionProvinceDAO) FindAllEnabledProvinces(tx *dbs.Tx) (result []*RegionProvince, err error) { func (this *RegionProvinceDAO) FindAllEnabledProvinces(tx *dbs.Tx) (result []*RegionProvince, err error) {
_, err = this.Query(tx). _, err = this.Query(tx).
State(RegionProvinceStateEnabled). State(RegionProvinceStateEnabled).
AscPk(). Asc(RegionProvinceField_ValueId).
Slice(&result). Slice(&result).
FindAll() FindAll()
return return
@@ -149,7 +159,7 @@ func (this *RegionProvinceDAO) UpdateProvinceCustom(tx *dbs.Tx, provinceId int64
} }
return this.Query(tx). return this.Query(tx).
Pk(provinceId). Attr("valueId", provinceId).
Set("customName", customName). Set("customName", customName).
Set("customCodes", customCodesJSON). Set("customCodes", customCodesJSON).
UpdateQuickly() UpdateQuickly()

View File

@@ -2,9 +2,22 @@ package regions
import "github.com/iwind/TeaGo/dbs" import "github.com/iwind/TeaGo/dbs"
const (
RegionProvinceField_Id dbs.FieldName = "id" // ID
RegionProvinceField_ValueId dbs.FieldName = "valueId" // 实际ID
RegionProvinceField_CountryId dbs.FieldName = "countryId" // 国家ID
RegionProvinceField_Name dbs.FieldName = "name" // 名称
RegionProvinceField_Codes dbs.FieldName = "codes" // 代号
RegionProvinceField_CustomName dbs.FieldName = "customName" // 自定义名称
RegionProvinceField_CustomCodes dbs.FieldName = "customCodes" // 自定义代号
RegionProvinceField_State dbs.FieldName = "state" // 状态
RegionProvinceField_DataId dbs.FieldName = "dataId" // 原始数据ID
)
// RegionProvince 区域-省份 // RegionProvince 区域-省份
type RegionProvince struct { type RegionProvince struct {
Id uint32 `field:"id"` // ID Id1 uint32 `field:"id"` // ID
ValueId uint32 `field:"valueId"` // 实际ID
CountryId uint32 `field:"countryId"` // 国家ID CountryId uint32 `field:"countryId"` // 国家ID
Name string `field:"name"` // 名称 Name string `field:"name"` // 名称
Codes dbs.JSON `field:"codes"` // 代号 Codes dbs.JSON `field:"codes"` // 代号
@@ -15,14 +28,15 @@ type RegionProvince struct {
} }
type RegionProvinceOperator struct { type RegionProvinceOperator struct {
Id interface{} // ID Id any // ID
CountryId interface{} // 国家ID ValueId any // 实际ID
Name interface{} // 名称 CountryId any // 国家ID
Codes interface{} // 代号 Name any // 名称
CustomName interface{} // 自定义名称 Codes any // 代号
CustomCodes interface{} // 自定义代号 CustomName any // 自定义名称
State interface{} // 状态 CustomCodes any // 自定义代号
DataId interface{} // 原始数据ID State any // 状态
DataId any // 原始数据ID
} }
func NewRegionProvinceOperator() *RegionProvinceOperator { func NewRegionProvinceOperator() *RegionProvinceOperator {

View File

@@ -41,7 +41,7 @@ func init() {
// EnableRegionTown 启用条目 // EnableRegionTown 启用条目
func (this *RegionTownDAO) EnableRegionTown(tx *dbs.Tx, id uint32) error { func (this *RegionTownDAO) EnableRegionTown(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionTownStateEnabled). Set("state", RegionTownStateEnabled).
Update() Update()
return err return err
@@ -50,7 +50,7 @@ func (this *RegionTownDAO) EnableRegionTown(tx *dbs.Tx, id uint32) error {
// DisableRegionTown 禁用条目 // DisableRegionTown 禁用条目
func (this *RegionTownDAO) DisableRegionTown(tx *dbs.Tx, id uint32) error { func (this *RegionTownDAO) DisableRegionTown(tx *dbs.Tx, id uint32) error {
_, err := this.Query(tx). _, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Set("state", RegionTownStateDisabled). Set("state", RegionTownStateDisabled).
Update() Update()
return err return err
@@ -59,7 +59,7 @@ func (this *RegionTownDAO) DisableRegionTown(tx *dbs.Tx, id uint32) error {
// FindEnabledRegionTown 查找启用中的区县 // FindEnabledRegionTown 查找启用中的区县
func (this *RegionTownDAO) FindEnabledRegionTown(tx *dbs.Tx, id int64) (*RegionTown, error) { func (this *RegionTownDAO) FindEnabledRegionTown(tx *dbs.Tx, id int64) (*RegionTown, error) {
result, err := this.Query(tx). result, err := this.Query(tx).
Pk(id). Attr("valueId", id).
Attr("state", RegionTownStateEnabled). Attr("state", RegionTownStateEnabled).
Find() Find()
if result == nil { if result == nil {
@@ -72,7 +72,7 @@ func (this *RegionTownDAO) FindEnabledRegionTown(tx *dbs.Tx, id int64) (*RegionT
func (this *RegionTownDAO) FindAllRegionTowns(tx *dbs.Tx) (result []*RegionTown, err error) { func (this *RegionTownDAO) FindAllRegionTowns(tx *dbs.Tx) (result []*RegionTown, err error) {
_, err = this.Query(tx). _, err = this.Query(tx).
State(RegionTownStateEnabled). State(RegionTownStateEnabled).
AscPk(). Asc(RegionTownField_ValueId).
Slice(&result). Slice(&result).
FindAll() FindAll()
return return
@@ -83,7 +83,7 @@ func (this *RegionTownDAO) FindAllRegionTownsWithCityId(tx *dbs.Tx, cityId int64
_, err = this.Query(tx). _, err = this.Query(tx).
State(RegionTownStateEnabled). State(RegionTownStateEnabled).
Attr("cityId", cityId). Attr("cityId", cityId).
AscPk(). Asc(RegionTownField_ValueId).
Slice(&result). Slice(&result).
FindAll() FindAll()
return return
@@ -96,14 +96,14 @@ func (this *RegionTownDAO) FindTownIdWithName(tx *dbs.Tx, cityId int64, townName
Where("(name=:townName OR customName=:townName OR JSON_CONTAINS(codes, :townNameJSON) OR JSON_CONTAINS(customCodes, :townNameJSON))"). Where("(name=:townName OR customName=:townName OR JSON_CONTAINS(codes, :townNameJSON) OR JSON_CONTAINS(customCodes, :townNameJSON))").
Param("townName", townName). Param("townName", townName).
Param("townNameJSON", strconv.Quote(townName)). // 查询的需要是个JSON字符串所以这里加双引号 Param("townNameJSON", strconv.Quote(townName)). // 查询的需要是个JSON字符串所以这里加双引号
ResultPk(). Result(RegionTownField_ValueId).
FindInt64Col(0) FindInt64Col(0)
} }
// FindRegionTownName 根据主键查找名称 // FindRegionTownName 根据主键查找名称
func (this *RegionTownDAO) FindRegionTownName(tx *dbs.Tx, id uint32) (string, error) { func (this *RegionTownDAO) FindRegionTownName(tx *dbs.Tx, id uint32) (string, error) {
return this.Query(tx). return this.Query(tx).
Pk(id). Attr("valueId", id).
Result("name"). Result("name").
FindStringCol("") FindStringCol("")
} }
@@ -118,7 +118,7 @@ func (this *RegionTownDAO) UpdateTownCustom(tx *dbs.Tx, townId int64, customName
return err return err
} }
return this.Query(tx). return this.Query(tx).
Pk(townId). Attr("valueId", townId).
Set("customName", customName). Set("customName", customName).
Set("customCodes", customCodesJSON). Set("customCodes", customCodesJSON).
UpdateQuickly() UpdateQuickly()
@@ -176,5 +176,18 @@ func (this *RegionTownDAO) CreateTown(tx *dbs.Tx, cityId int64, townName string)
op.Codes = codes op.Codes = codes
op.State = RegionTownStateEnabled op.State = RegionTownStateEnabled
return this.SaveInt64(tx, op) townId, err := this.SaveInt64(tx, op)
if err != nil {
return 0, err
}
err = this.Query(tx).
Pk(townId).
Set(RegionTownField_ValueId, townId).
UpdateQuickly()
if err != nil {
return 0, err
}
return townId, nil
} }

View File

@@ -2,9 +2,22 @@ package regions
import "github.com/iwind/TeaGo/dbs" import "github.com/iwind/TeaGo/dbs"
const (
RegionTownField_Id dbs.FieldName = "id" // ID
RegionTownField_ValueId dbs.FieldName = "valueId" // 真实ID
RegionTownField_CityId dbs.FieldName = "cityId" // 城市ID
RegionTownField_Name dbs.FieldName = "name" // 名称
RegionTownField_Codes dbs.FieldName = "codes" // 代号
RegionTownField_CustomName dbs.FieldName = "customName" // 自定义名称
RegionTownField_CustomCodes dbs.FieldName = "customCodes" // 自定义代号
RegionTownField_State dbs.FieldName = "state" // 状态
RegionTownField_DataId dbs.FieldName = "dataId" // 原始数据ID
)
// RegionTown 区域-省份 // RegionTown 区域-省份
type RegionTown struct { type RegionTown struct {
Id uint32 `field:"id"` // ID Id1 uint32 `field:"id"` // ID
ValueId uint32 `field:"valueId"` // 真实ID
CityId uint32 `field:"cityId"` // 城市ID CityId uint32 `field:"cityId"` // 城市ID
Name string `field:"name"` // 名称 Name string `field:"name"` // 名称
Codes dbs.JSON `field:"codes"` // 代号 Codes dbs.JSON `field:"codes"` // 代号
@@ -15,14 +28,15 @@ type RegionTown struct {
} }
type RegionTownOperator struct { type RegionTownOperator struct {
Id interface{} // ID Id any // ID
CityId interface{} // 城市ID ValueId any // 真实ID
Name interface{} // 名称 CityId any // 城市ID
Codes interface{} // 代号 Name any // 名称
CustomName interface{} // 自定义名称 Codes any // 代号
CustomCodes interface{} // 自定义代号 CustomName any // 自定义名称
State interface{} // 状态 CustomCodes any // 自定义代号
DataId interface{} // 原始数据ID State any // 状态
DataId any // 原始数据ID
} }
func NewRegionTownOperator() *RegionTownOperator { func NewRegionTownOperator() *RegionTownOperator {

View File

@@ -309,7 +309,7 @@ func (this *IPLibraryFileService) CheckCountriesWithIPLibraryFileId(ctx context.
} }
for _, similarCountry := range similarCountries { for _, similarCountry := range similarCountries {
pbMissingCountry.SimilarCountries = append(pbMissingCountry.SimilarCountries, &pb.RegionCountry{ pbMissingCountry.SimilarCountries = append(pbMissingCountry.SimilarCountries, &pb.RegionCountry{
Id: int64(similarCountry.Id), Id: int64(similarCountry.ValueId),
Name: similarCountry.Name, Name: similarCountry.Name,
DisplayName: similarCountry.DisplayName(), DisplayName: similarCountry.DisplayName(),
}) })
@@ -391,7 +391,7 @@ func (this *IPLibraryFileService) CheckProvincesWithIPLibraryFileId(ctx context.
for _, similarProvince := range similarProvinces { for _, similarProvince := range similarProvinces {
pbMissingProvince.SimilarProvinces = append(pbMissingProvince.SimilarProvinces, &pb.RegionProvince{ pbMissingProvince.SimilarProvinces = append(pbMissingProvince.SimilarProvinces, &pb.RegionProvince{
Id: int64(similarProvince.Id), Id: int64(similarProvince.ValueId),
Name: similarProvince.Name, Name: similarProvince.Name,
DisplayName: similarProvince.DisplayName(), DisplayName: similarProvince.DisplayName(),
}) })
@@ -482,7 +482,7 @@ func (this *IPLibraryFileService) CheckCitiesWithIPLibraryFileId(ctx context.Con
for _, similarCity := range similarCities { for _, similarCity := range similarCities {
pbMissingCity.SimilarCities = append(pbMissingCity.SimilarCities, &pb.RegionCity{ pbMissingCity.SimilarCities = append(pbMissingCity.SimilarCities, &pb.RegionCity{
Id: int64(similarCity.Id), Id: int64(similarCity.ValueId),
Name: similarCity.Name, Name: similarCity.Name,
DisplayName: similarCity.DisplayName(), DisplayName: similarCity.DisplayName(),
}) })
@@ -597,7 +597,7 @@ func (this *IPLibraryFileService) CheckTownsWithIPLibraryFileId(ctx context.Cont
for _, similarTown := range similarTowns { for _, similarTown := range similarTowns {
pbMissingTown.SimilarTowns = append(pbMissingTown.SimilarTowns, &pb.RegionTown{ pbMissingTown.SimilarTowns = append(pbMissingTown.SimilarTowns, &pb.RegionTown{
Id: int64(similarTown.Id), Id: int64(similarTown.ValueId),
Name: similarTown.Name, Name: similarTown.Name,
DisplayName: similarTown.DisplayName(), DisplayName: similarTown.DisplayName(),
}) })
@@ -654,7 +654,7 @@ func (this *IPLibraryFileService) CheckProvidersWithIPLibraryFileId(ctx context.
} }
for _, similarProvider := range similarProviders { for _, similarProvider := range similarProviders {
pbMissingProvider.SimilarProviders = append(pbMissingProvider.SimilarProviders, &pb.RegionProvider{ pbMissingProvider.SimilarProviders = append(pbMissingProvider.SimilarProviders, &pb.RegionProvider{
Id: int64(similarProvider.Id), Id: int64(similarProvider.ValueId),
Name: similarProvider.Name, Name: similarProvider.Name,
DisplayName: similarProvider.DisplayName(), DisplayName: similarProvider.DisplayName(),
}) })

View File

@@ -49,7 +49,7 @@ func (this *RegionCityService) FindAllEnabledRegionCities(ctx context.Context, r
} }
pbProvince = &pb.RegionProvince{ pbProvince = &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.Name, Name: province.Name,
Codes: province.DecodeCodes(), Codes: province.DecodeCodes(),
DisplayName: province.DisplayName(), DisplayName: province.DisplayName(),
@@ -57,7 +57,7 @@ func (this *RegionCityService) FindAllEnabledRegionCities(ctx context.Context, r
} }
pbCities = append(pbCities, &pb.RegionCity{ pbCities = append(pbCities, &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.Name, Name: city.Name,
Codes: city.DecodeCodes(), Codes: city.DecodeCodes(),
RegionProvinceId: int64(city.ProvinceId), RegionProvinceId: int64(city.ProvinceId),
@@ -108,7 +108,7 @@ func (this *RegionCityService) FindAllRegionCities(ctx context.Context, req *pb.
} }
pbProvince = &pb.RegionProvince{ pbProvince = &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.Name, Name: province.Name,
Codes: province.DecodeCodes(), Codes: province.DecodeCodes(),
CustomName: province.CustomName, CustomName: province.CustomName,
@@ -118,7 +118,7 @@ func (this *RegionCityService) FindAllRegionCities(ctx context.Context, req *pb.
} }
pbCities = append(pbCities, &pb.RegionCity{ pbCities = append(pbCities, &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.Name, Name: city.Name,
Codes: city.DecodeCodes(), Codes: city.DecodeCodes(),
RegionProvinceId: int64(city.ProvinceId), RegionProvinceId: int64(city.ProvinceId),
@@ -155,7 +155,7 @@ func (this *RegionCityService) FindAllRegionCitiesWithRegionProvinceId(ctx conte
var pbProvince = &pb.RegionProvince{Id: provinceId} var pbProvince = &pb.RegionProvince{Id: provinceId}
pbCities = append(pbCities, &pb.RegionCity{ pbCities = append(pbCities, &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.Name, Name: city.Name,
Codes: city.DecodeCodes(), Codes: city.DecodeCodes(),
RegionProvinceId: int64(city.ProvinceId), RegionProvinceId: int64(city.ProvinceId),
@@ -192,7 +192,7 @@ func (this *RegionCityService) FindEnabledRegionCity(ctx context.Context, req *p
return &pb.FindEnabledRegionCityResponse{ return &pb.FindEnabledRegionCityResponse{
RegionCity: &pb.RegionCity{ RegionCity: &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.Name, Name: city.Name,
Codes: city.DecodeCodes(), Codes: city.DecodeCodes(),
RegionProvinceId: int64(city.ProvinceId), RegionProvinceId: int64(city.ProvinceId),
@@ -223,7 +223,7 @@ func (this *RegionCityService) FindRegionCity(ctx context.Context, req *pb.FindR
return &pb.FindRegionCityResponse{ return &pb.FindRegionCityResponse{
RegionCity: &pb.RegionCity{ RegionCity: &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.Name, Name: city.Name,
Codes: city.DecodeCodes(), Codes: city.DecodeCodes(),
RegionProvinceId: int64(city.ProvinceId), RegionProvinceId: int64(city.ProvinceId),

View File

@@ -40,13 +40,14 @@ func (this *RegionCountryService) FindAllEnabledRegionCountries(ctx context.Cont
} }
result = append(result, &pb.RegionCountry{ result = append(result, &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.Name, Name: country.Name,
Codes: country.DecodeCodes(), Codes: country.DecodeCodes(),
Pinyin: pinyinStrings, Pinyin: pinyinStrings,
CustomName: country.CustomName, CustomName: country.CustomName,
CustomCodes: country.DecodeCustomCodes(), CustomCodes: country.DecodeCustomCodes(),
DisplayName: country.DisplayName(), DisplayName: country.DisplayName(),
IsCommon: country.IsCommon,
}) })
} }
return &pb.FindAllEnabledRegionCountriesResponse{ return &pb.FindAllEnabledRegionCountriesResponse{
@@ -74,7 +75,7 @@ func (this *RegionCountryService) FindEnabledRegionCountry(ctx context.Context,
} }
return &pb.FindEnabledRegionCountryResponse{RegionCountry: &pb.RegionCountry{ return &pb.FindEnabledRegionCountryResponse{RegionCountry: &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.Name, Name: country.Name,
Codes: country.DecodeCodes(), Codes: country.DecodeCodes(),
CustomName: country.CustomName, CustomName: country.CustomName,
@@ -110,13 +111,14 @@ func (this *RegionCountryService) FindAllRegionCountries(ctx context.Context, re
} }
result = append(result, &pb.RegionCountry{ result = append(result, &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.Name, Name: country.Name,
Codes: country.DecodeCodes(), Codes: country.DecodeCodes(),
Pinyin: pinyinStrings, Pinyin: pinyinStrings,
CustomName: country.CustomName, CustomName: country.CustomName,
CustomCodes: country.DecodeCustomCodes(), CustomCodes: country.DecodeCustomCodes(),
DisplayName: country.DisplayName(), DisplayName: country.DisplayName(),
IsCommon: country.IsCommon,
}) })
} }
return &pb.FindAllRegionCountriesResponse{ return &pb.FindAllRegionCountriesResponse{
@@ -143,12 +145,13 @@ func (this *RegionCountryService) FindRegionCountry(ctx context.Context, req *pb
} }
return &pb.FindRegionCountryResponse{RegionCountry: &pb.RegionCountry{ return &pb.FindRegionCountryResponse{RegionCountry: &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.Name, Name: country.Name,
Codes: country.DecodeCodes(), Codes: country.DecodeCodes(),
CustomName: country.CustomName, CustomName: country.CustomName,
CustomCodes: country.DecodeCustomCodes(), CustomCodes: country.DecodeCustomCodes(),
DisplayName: country.DisplayName(), DisplayName: country.DisplayName(),
IsCommon: country.IsCommon,
}}, nil }}, nil
} }

View File

@@ -30,7 +30,7 @@ func (this *RegionProviderService) FindAllEnabledRegionProviders(ctx context.Con
var pbProviders = []*pb.RegionProvider{} var pbProviders = []*pb.RegionProvider{}
for _, provider := range providers { for _, provider := range providers {
pbProviders = append(pbProviders, &pb.RegionProvider{ pbProviders = append(pbProviders, &pb.RegionProvider{
Id: int64(provider.Id), Id: int64(provider.ValueId),
Name: provider.Name, Name: provider.Name,
Codes: provider.DecodeCodes(), Codes: provider.DecodeCodes(),
CustomName: provider.CustomName, CustomName: provider.CustomName,
@@ -65,7 +65,7 @@ func (this *RegionProviderService) FindEnabledRegionProvider(ctx context.Context
return &pb.FindEnabledRegionProviderResponse{ return &pb.FindEnabledRegionProviderResponse{
RegionProvider: &pb.RegionProvider{ RegionProvider: &pb.RegionProvider{
Id: int64(provider.Id), Id: int64(provider.ValueId),
Name: provider.Name, Name: provider.Name,
Codes: provider.DecodeCodes(), Codes: provider.DecodeCodes(),
CustomName: provider.CustomName, CustomName: provider.CustomName,
@@ -91,7 +91,7 @@ func (this *RegionProviderService) FindAllRegionProviders(ctx context.Context, r
var pbProviders = []*pb.RegionProvider{} var pbProviders = []*pb.RegionProvider{}
for _, provider := range providers { for _, provider := range providers {
pbProviders = append(pbProviders, &pb.RegionProvider{ pbProviders = append(pbProviders, &pb.RegionProvider{
Id: int64(provider.Id), Id: int64(provider.ValueId),
Name: provider.Name, Name: provider.Name,
Codes: provider.DecodeCodes(), Codes: provider.DecodeCodes(),
CustomName: provider.CustomName, CustomName: provider.CustomName,
@@ -125,7 +125,7 @@ func (this *RegionProviderService) FindRegionProvider(ctx context.Context, req *
return &pb.FindRegionProviderResponse{ return &pb.FindRegionProviderResponse{
RegionProvider: &pb.RegionProvider{ RegionProvider: &pb.RegionProvider{
Id: int64(provider.Id), Id: int64(provider.ValueId),
Name: provider.Name, Name: provider.Name,
Codes: provider.DecodeCodes(), Codes: provider.DecodeCodes(),
CustomName: provider.CustomName, CustomName: provider.CustomName,

View File

@@ -29,7 +29,7 @@ func (this *RegionProvinceService) FindAllEnabledRegionProvincesWithCountryId(ct
result := []*pb.RegionProvince{} result := []*pb.RegionProvince{}
for _, province := range provinces { for _, province := range provinces {
result = append(result, &pb.RegionProvince{ result = append(result, &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.Name, Name: province.Name,
Codes: province.DecodeCodes(), Codes: province.DecodeCodes(),
CustomName: province.CustomName, CustomName: province.CustomName,
@@ -64,7 +64,7 @@ func (this *RegionProvinceService) FindEnabledRegionProvince(ctx context.Context
return &pb.FindEnabledRegionProvinceResponse{ return &pb.FindEnabledRegionProvinceResponse{
RegionProvince: &pb.RegionProvince{ RegionProvince: &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.Name, Name: province.Name,
Codes: province.DecodeCodes(), Codes: province.DecodeCodes(),
CustomName: province.CustomName, CustomName: province.CustomName,
@@ -91,7 +91,7 @@ func (this *RegionProvinceService) FindAllRegionProvincesWithRegionCountryId(ctx
var result = []*pb.RegionProvince{} var result = []*pb.RegionProvince{}
for _, province := range provinces { for _, province := range provinces {
result = append(result, &pb.RegionProvince{ result = append(result, &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.Name, Name: province.Name,
Codes: province.DecodeCodes(), Codes: province.DecodeCodes(),
CustomName: province.CustomName, CustomName: province.CustomName,
@@ -125,7 +125,7 @@ func (this *RegionProvinceService) FindRegionProvince(ctx context.Context, req *
return &pb.FindRegionProvinceResponse{ return &pb.FindRegionProvinceResponse{
RegionProvince: &pb.RegionProvince{ RegionProvince: &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.Name, Name: province.Name,
Codes: province.DecodeCodes(), Codes: province.DecodeCodes(),
CustomName: province.CustomName, CustomName: province.CustomName,

View File

@@ -48,7 +48,7 @@ func (this *RegionTownService) FindAllRegionTowns(ctx context.Context, req *pb.F
} }
pbCity = &pb.RegionCity{ pbCity = &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.Name, Name: city.Name,
Codes: city.DecodeCodes(), Codes: city.DecodeCodes(),
CustomName: city.CustomName, CustomName: city.CustomName,
@@ -58,7 +58,7 @@ func (this *RegionTownService) FindAllRegionTowns(ctx context.Context, req *pb.F
} }
pbTowns = append(pbTowns, &pb.RegionTown{ pbTowns = append(pbTowns, &pb.RegionTown{
Id: int64(town.Id), Id: int64(town.ValueId),
Name: town.Name, Name: town.Name,
Codes: town.DecodeCodes(), Codes: town.DecodeCodes(),
RegionCityId: int64(town.CityId), RegionCityId: int64(town.CityId),
@@ -95,7 +95,7 @@ func (this *RegionTownService) FindAllRegionTownsWithRegionCityId(ctx context.Co
var pbCity = &pb.RegionCity{Id: cityId} var pbCity = &pb.RegionCity{Id: cityId}
pbTowns = append(pbTowns, &pb.RegionTown{ pbTowns = append(pbTowns, &pb.RegionTown{
Id: int64(town.Id), Id: int64(town.ValueId),
Name: town.Name, Name: town.Name,
Codes: town.DecodeCodes(), Codes: town.DecodeCodes(),
RegionCityId: int64(town.CityId), RegionCityId: int64(town.CityId),
@@ -131,7 +131,7 @@ func (this *RegionTownService) FindRegionTown(ctx context.Context, req *pb.FindR
return &pb.FindRegionTownResponse{ return &pb.FindRegionTownResponse{
RegionTown: &pb.RegionTown{ RegionTown: &pb.RegionTown{
Id: int64(town.Id), Id: int64(town.ValueId),
Name: town.Name, Name: town.Name,
Codes: town.DecodeCodes(), Codes: town.DecodeCodes(),
RegionCityId: int64(town.CityId), RegionCityId: int64(town.CityId),

View File

@@ -62,15 +62,15 @@ func (this *ServerRegionCityMonthlyStatService) FindTopServerRegionCityMonthlySt
continue continue
} }
pbStat.RegionCountry = &pb.RegionCountry{ pbStat.RegionCountry = &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.DisplayName(), Name: country.DisplayName(),
} }
pbStat.RegionProvince = &pb.RegionProvince{ pbStat.RegionProvince = &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.DisplayName(), Name: province.DisplayName(),
} }
pbStat.RegionCity = &pb.RegionCity{ pbStat.RegionCity = &pb.RegionCity{
Id: int64(city.Id), Id: int64(city.ValueId),
Name: city.DisplayName(), Name: city.DisplayName(),
} }
pbStats = append(pbStats, pbStat) pbStats = append(pbStats, pbStat)

View File

@@ -46,7 +46,7 @@ func (this *ServerRegionCountryMonthlyStatService) FindTopServerRegionCountryMon
continue continue
} }
pbStat.RegionCountry = &pb.RegionCountry{ pbStat.RegionCountry = &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.DisplayName(), Name: country.DisplayName(),
} }

View File

@@ -45,7 +45,7 @@ func (this *ServerRegionProviderMonthlyStatService) FindTopServerRegionProviderM
continue continue
} }
pbStat.RegionProvider = &pb.RegionProvider{ pbStat.RegionProvider = &pb.RegionProvider{
Id: int64(provider.Id), Id: int64(provider.ValueId),
Name: provider.DisplayName(), Name: provider.DisplayName(),
} }
pbStats = append(pbStats, pbStat) pbStats = append(pbStats, pbStat)

View File

@@ -52,11 +52,11 @@ func (this *ServerRegionProvinceMonthlyStatService) FindTopServerRegionProvinceM
continue continue
} }
pbStat.RegionCountry = &pb.RegionCountry{ pbStat.RegionCountry = &pb.RegionCountry{
Id: int64(country.Id), Id: int64(country.ValueId),
Name: country.DisplayName(), Name: country.DisplayName(),
} }
pbStat.RegionProvince = &pb.RegionProvince{ pbStat.RegionProvince = &pb.RegionProvince{
Id: int64(province.Id), Id: int64(province.ValueId),
Name: province.DisplayName(), Name: province.DisplayName(),
} }
pbStats = append(pbStats, pbStat) pbStats = append(pbStats, pbStat)

File diff suppressed because it is too large Load Diff