Documentation ¶
Overview ¶
Package district Wrote by yijian on 2024/03/09
Package district Wrote by yijian on 2024/03/09
Package district Wrote by yijian on 2024/03/09
Index ¶
- func CacheMetricFPrintf(w io.Writer)
- func GenerateCsv(districtTable *Table, csvFilepath, csvDelimiter string, withCode bool) error
- func GenerateJson(districtTable *Table, jsonFilepath string, withIndent bool, ...) error
- func GenerateSql(districtTable *Table, sqlFilepath, tableName string) error
- func IsCityDistrictCode(code uint32) bool
- func IsCountyDistrictCode(code uint32) bool
- func IsHongKongMacauTaiwan(name string) bool
- func IsMunicipalityCode(code uint32) bool
- func IsProvinceDistrictCode(code uint32) bool
- func Md5Sum(data string) string
- func PerfectNameOfProvincialAdminRegion(name string) string
- type CacheMetric
- type CityDistrict
- type Code
- type District
- type Name
- type ProvinceDistrict
- type Query
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheMetricFPrintf ¶
func GenerateCsv ¶
func GenerateJson ¶
func GenerateSql ¶
func IsCityDistrictCode ¶ added in v0.0.6
func IsCountyDistrictCode ¶ added in v0.0.6
func IsHongKongMacauTaiwan ¶ added in v0.0.6
IsHongKongMacauTaiwan 判断是否为香港/澳门/台湾
func IsMunicipalityCode ¶ added in v0.0.6
IsMunicipalityCode 是否为直辖市
func IsProvinceDistrictCode ¶ added in v0.0.6
func PerfectNameOfProvincialAdminRegion ¶
PerfectNameOfProvincialAdminRegion 完美省级行政区名 name 省级行政区全名或者简名(非简称) 数据参考:https://www.gov.cn/test/2006-04/04/content_244716.htm
Types ¶
type CacheMetric ¶
type CacheMetric struct { EntryCount int64 `json:"entry_count"` ExpiredCount int64 `json:"expired_count"` EvacuateCount int64 `json:"evacuate_count"` LookupCount int64 `json:"lookup_count"` AverageAccessTime int64 `json:"average_access_time"` HitCount int64 `json:"hit_count"` MissCount int64 `json:"miss_count"` OverwriteCount int64 `json:"overwrite_count"` TouchedCount int64 `json:"touched_count"` HitRate float64 `json:"hit_rate"` }
CacheMetric 缓存的度量数据
func GetCacheMetric ¶
func GetCacheMetric() *CacheMetric
func (*CacheMetric) String ¶
func (c *CacheMetric) String() (string, error)
type CityDistrict ¶
type CityDistrict struct { Code uint32 `json:"code"` Name string `json:"name"` // 行政区名称 Level uint32 `json:"level"` // 行政区级别(1 省/自治区/直辖市,2 市/州/盟,3 县/县级市/旗) CountyCity bool `json:"county_city"` // 县级市 CountyDistrictTable map[uint32]District `json:"-"` Counties []District `json:"counties,omitempty"` }
CityDistrict 市/州/盟
type Code ¶
type Name ¶
type Name struct { ProvinceName string `gorm:"column:f_province_name" json:"province_name,omitempty"` CityName string `gorm:"column:f_city_name" json:"city_name,omitempty"` CountyName string `gorm:"column:f_county_name" json:"county_name,omitempty"` }
Name 行政区名(字符集需同 DB 等保持一致)
type ProvinceDistrict ¶
type ProvinceDistrict struct { Code uint32 `json:"code"` Name string `json:"name"` // 行政区名称 Level uint32 `json:"level"` // 行政区级别(1 省/自治区/直辖市,2 市/州/盟,3 县/县级市/旗) Municipality bool `json:"municipality"` // 直辖市 CityDistrictTable map[uint32]CityDistrict `json:"-"` Cities []CityDistrict `json:"cities,omitempty"` }
ProvinceDistrict 省/自治区/直辖市
type Query ¶
Query 行政区查询器
func (*Query) GetCountyCount ¶ added in v0.0.7
GetCountyCount 取得县/县级市/旗数,像东莞市没有
func (*Query) GetDistrictCode ¶
GetDistrictCode 通过行政区名取得行政区代码 返回值: 1)成功返回非 nil 的 DistrictCode,同时 error 值为 nil ; 2)不存在返回 nil 的 DistrictCode,同时 error 值为 nil ; 3)出错返回 nil 的 DistrictCode,同时 error 值不为 nil 。
type Table ¶
type Table struct { ProvinceDistrictTable map[uint32]ProvinceDistrict `json:"-"` Provinces []ProvinceDistrict `json:"provinces,omitempty"` }
Click to show internal directories.
Click to hide internal directories.