xcity

package
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause-Clear Imports: 9 Imported by: 0

Documentation

Overview

省市区模块,高德省市区

Index

Constants

This section is empty.

Variables

View Source
var CityCsv string

Functions

func Name2Id added in v0.2.16

func Name2Id(name string, is_like bool) uint

根据名称返回ID

name	城市名称
is_like	是否模糊匹配

func Regedit

func Regedit(c *Config)

入口配置

Types

type City

type City struct {
	Adcode   uint   `gorm:"column:ad_code;primaryKey;comment:省市区的ADCode;not null" json:"ad_code" form:"ad_code"`                     // 省市区的ADCode
	CityCode string `gorm:"column:cidy_code;type:VARCHAR(4);comment:省市区的CityCode;index:city_code" json:"cidy_code" form:"cidy_code"` // 省市区的CityCode
	Name     string `gorm:"column:name;type:VARCHAR(100);comment:省市区的中文名;index:name" json:"name" form:"name"`                        // 中文名
}

城市的表结构信息

func Ad2info

func Ad2info(adcode uint) (*City, error)

Adcode换取城市详情信息

adcode	省市区的Adcode值【六位数字】

func AreaList

func AreaList(city_code uint) ([]City, error)

获取区县列表信息

city_code	市区code

func CityList

func CityList(province_code uint) ([]City, error)

获取市区列表信息

province_code	省/直辖市code

func ProvinceList

func ProvinceList() ([]City, error)

获取省份信息

func (*City) TableName

func (c *City) TableName() string

获取表名

type CityTree added in v0.1.32

type CityTree struct {
	Province *City `json:"province"` // 省
	Area     *City `json:"area"`     // 市
	Town     *City `json:"town"`     // 区
}

省市区详情结构

func Ad2tree added in v0.1.32

func Ad2tree(code uint) (*CityTree, error)

获取省市区详情信息

code	高德省市区代码

type Config

type Config struct {
	DB       *gorm.DB
	CityName string // 省市区存储的表名
}

省市区为从高德进行下载的省市区信息,然后另存为的CSV文件,更新时请重新下载保存到此目录下 CSV文件要求:使用,分割各个列,然后使用换行符分割各个行,内容编码为GBK编码 此模块依赖xlog模块进行日志输出/入库 下载地址:https://lbs.amap.com/api/webservice/download

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL