base.js
914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* @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;