1.0.3 • Published 8 years ago

egg-city v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

egg-city

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-city --save

Usage

// {app_root}/config/plugin.js
exports.city = {
  enable: true,
  package: 'egg-city',
};

Configuration

// {app_root}/config/config.default.js
exports.city = {
};

see config/config.default.js for more detail.

Example

// {app_root}/app/controller/home.js
'use strict';

class HomeController extends app.Controller {
  async index() {

    /**
    * 获取城市信息
    * @method getCity
    * @param {string} queryInfo - 根据名称或代号进行查询,名称为中文,代号为6位数字组成的字符串
    * @returns {array} 数组成员为object类型,object中包含了相应的省、市、区所有信息
	* @description 返回值成员的属性包括:
	* @description name(城市名称)
	* @description code(城市代号)
	* @description distinctInfo(拥有的所有“区/县”信息,若查询本身为“县/区”级别,则不含该字段)
	* @description provinceInfo(所属“省份”信息,若查询本身为“省”级别,则不含该字段)
	* @description cityInfo(包含/所属“市”信息,若查询本身为“市”级别,则不含该字段)
    */
    const cityInfo = await this.service.city.getCity('四川');
  }
}
module.exports = HomeController;

Questions & Suggestions

Please open an issue here.

License

MIT