base.js 914 Bytes
/*
 * @Author: limin 
 * @Date: 2019-11-21 11:18:30 
 * @Last Modified by:   limin 
 * @Last Modified time: 2019-11-21 11:18:30 
 */

const Service = require("egg").Service;

class BaseService extends Service {
  constructor(ctx) {
    super(ctx);
    this.session = ctx.session;
    this.ProvinceModel = ctx.model.TProvince;
    this.CityModel = ctx.model.TCity;
    this.ServerResponse = ctx.response.ServerResponse;
    this.ServerResponseCode = ctx.response.ServerResponseCode;
  }

  /**
   *
   * @param field {String}
   * @param value {String}
   * @return {Promise.<boolean>}
   */
  async provinces() {
    return await this.ProvinceModel.findAll();
  }
  /**
   *
   * @param field {String}
   * @param value {String}
   * @return {Promise.<boolean>}
   */
  async cities_by_pid(pid) {
    return await this.CityModel.findAll({
      where:{'prov_code':pid}
    });
  }
}

module.exports = BaseService;