q-koa 7.7.3 → 7.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/file/plugins/administrator/controller.js +1 -1
- package/core/file/plugins/administrator/model.js +7 -9
- package/core/file/plugins/administrator/validate.js +1 -1
- package/core/file/plugins/alipay/controller.js +1 -1
- package/core/file/plugins/cloudfunction/model.js +3 -3
- package/core/file/plugins/common/controller.js +1 -1
- package/core/file/plugins/common/validate.js +14 -13
- package/core/file/plugins/douyin/controller.js +1 -7
- package/core/file/plugins/douyin/validate.js +17 -19
- package/core/file/plugins/douyin_user/model.js +1 -1
- package/core/file/plugins/good_sku/controller.js +1 -1
- package/core/file/plugins/h5_user/model.js +1 -1
- package/core/file/plugins/lang/model.js +3 -3
- package/core/file/plugins/language/model.js +5 -6
- package/core/file/plugins/log/controller.js +1 -1
- package/core/file/plugins/log/model.js +1 -1
- package/core/file/plugins/model/controller.js +1 -1
- package/core/file/plugins/model/model.js +1 -1
- package/core/file/plugins/model/validate.js +10 -13
- package/core/file/plugins/model_attributes/model.js +1 -1
- package/core/file/plugins/mp_user/model.js +1 -1
- package/core/file/plugins/permission/model.js +1 -1
- package/core/file/plugins/role/controller.js +1 -1
- package/core/file/plugins/role/model.js +1 -1
- package/core/file/plugins/role_permission/controller.js +1 -1
- package/core/file/plugins/role_permission/model.js +7 -8
- package/core/file/plugins/routes/controller.js +1 -1
- package/core/file/plugins/routes/model.js +1 -1
- package/core/file/plugins/setting/afterExecute.js +1 -1
- package/core/file/plugins/setting/controller.js +1 -1
- package/core/file/plugins/setting/model.js +1 -1
- package/core/file/plugins/setting/validate.js +13 -19
- package/core/file/plugins/system/controller.js +1 -6
- package/core/file/plugins/system/service.js +1 -1
- package/core/file/plugins/system/validate.js +20 -14
- package/core/file/plugins/todolist/model.js +1 -1
- package/core/file/plugins/toutiao/controller.js +1 -6
- package/core/file/plugins/toutiao_user/model.js +1 -1
- package/core/file/plugins/user/afterExecute.js +38 -33
- package/core/file/plugins/user/controller.js +1 -1
- package/core/file/plugins/user/model.js +29 -18
- package/core/file/plugins/user/test.js +53 -38
- package/core/file/plugins/user/validate.js +7 -8
- package/core/file/plugins/video/controller.js +4 -6
- package/core/file/plugins/video/validate.js +4 -4
- package/core/file/plugins/weixin/controller.js +1 -1
- package/core/file/plugins/weixin/service.js +1 -1
- package/core/file/plugins/weixin/validate.js +26 -27
- package/core/file/services/aliSms.js +29 -28
- package/core/file/services/alipay.js +1 -1
- package/core/file/services/amap.js +6 -6
- package/core/file/services/douyin.js +1 -1
- package/core/file/services/express.js +4 -4
- package/core/file/services/geo.js +1 -1
- package/core/file/services/toutiao.js +1 -1
- package/core/file/services/weixin.js +21 -12
- package/core/file/services/weixinMP.js +1 -1
- package/core/file/utils/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const util = require('util')
|
|
2
2
|
const axios = require('axios')
|
|
3
3
|
|
|
4
|
-
const { lodash } = require('
|
|
4
|
+
const { lodash } = require('q-koa')
|
|
5
5
|
const getAccessTokenUrl =
|
|
6
6
|
'https://developer.toutiao.com/api/apps/token?grant_type=%s&appid=%s&secret=%s'
|
|
7
7
|
const createQRCodeUrl = 'https://developer.toutiao.com/api/apps/qrcode'
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
const util = require('util')
|
|
2
2
|
const axios = require('axios')
|
|
3
3
|
const getAccessTokenUrl = `https://api.weixin.qq.com/cgi-bin/token?grant_type=%s&appid=%s&secret=%s`
|
|
4
|
-
const getTicketUrl =
|
|
4
|
+
const getTicketUrl =
|
|
5
|
+
'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi'
|
|
5
6
|
const sha1 = require('sha1')
|
|
6
7
|
const LRU = require('lru-cache')
|
|
7
8
|
const cache = new LRU({
|
|
8
9
|
max: 100,
|
|
9
|
-
maxAge: 1000 * 60 * 60
|
|
10
|
+
maxAge: 1000 * 60 * 60,
|
|
10
11
|
})
|
|
11
|
-
const {
|
|
12
|
-
lodash
|
|
13
|
-
} = require('multiple-quick-koa')
|
|
12
|
+
const { lodash } = require('q-koa')
|
|
14
13
|
|
|
15
14
|
module.exports = class Singleton {
|
|
16
15
|
constructor(config) {
|
|
@@ -24,7 +23,7 @@ module.exports = class Singleton {
|
|
|
24
23
|
* 单例模式
|
|
25
24
|
*/
|
|
26
25
|
if (!Singleton.instance) {
|
|
27
|
-
|
|
26
|
+
Singleton.instance = this
|
|
28
27
|
}
|
|
29
28
|
const previous = Singleton.instance.getConfig()
|
|
30
29
|
if (!lodash.isEqual(previous, config)) {
|
|
@@ -33,7 +32,8 @@ module.exports = class Singleton {
|
|
|
33
32
|
return Singleton.instance
|
|
34
33
|
}
|
|
35
34
|
init() {
|
|
36
|
-
if (!this.config.appid || !this.config.secrect)
|
|
35
|
+
if (!this.config.appid || !this.config.secrect)
|
|
36
|
+
throw new Error('没有配置appid或secrect')
|
|
37
37
|
}
|
|
38
38
|
async getAccessToken() {
|
|
39
39
|
const { appid, secrect, grant_type } = this.config
|
|
@@ -41,7 +41,7 @@ module.exports = class Singleton {
|
|
|
41
41
|
return cache.get('access_token')
|
|
42
42
|
}
|
|
43
43
|
const url = util.format(getAccessTokenUrl, grant_type, appid, secrect)
|
|
44
|
-
const result = await axios.get(url).then(res => res.data)
|
|
44
|
+
const result = await axios.get(url).then((res) => res.data)
|
|
45
45
|
if (result.errcode) throw new Error(result.errmsg)
|
|
46
46
|
|
|
47
47
|
cache.set('access_token', result.access_token)
|
|
@@ -51,7 +51,7 @@ module.exports = class Singleton {
|
|
|
51
51
|
async getTicket() {
|
|
52
52
|
const access_token = await this.getAccessToken()
|
|
53
53
|
const url = util.format(getTicketUrl, access_token)
|
|
54
|
-
const result = await axios.get(url).then(res => res.data)
|
|
54
|
+
const result = await axios.get(url).then((res) => res.data)
|
|
55
55
|
if (result.errcode) throw new Error(result.errmsg)
|
|
56
56
|
|
|
57
57
|
cache.set('ticket', result.ticket)
|
|
@@ -68,12 +68,21 @@ module.exports = class Singleton {
|
|
|
68
68
|
timestamp,
|
|
69
69
|
url,
|
|
70
70
|
jsapi_ticket,
|
|
71
|
-
signature: sha1(
|
|
71
|
+
signature: sha1(
|
|
72
|
+
'jsapi_ticket=' +
|
|
73
|
+
jsapi_ticket +
|
|
74
|
+
'&noncestr=' +
|
|
75
|
+
noncestr +
|
|
76
|
+
'×tamp=' +
|
|
77
|
+
timestamp +
|
|
78
|
+
'&url=' +
|
|
79
|
+
url
|
|
80
|
+
),
|
|
72
81
|
}
|
|
73
82
|
return result
|
|
74
83
|
}
|
|
75
84
|
|
|
76
|
-
getConfig
|
|
85
|
+
getConfig() {
|
|
77
86
|
return this.config
|
|
78
87
|
}
|
|
79
|
-
}
|
|
88
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const util = require('util')
|
|
2
2
|
const axios = require('axios')
|
|
3
3
|
|
|
4
|
-
const { lodash } = require('
|
|
4
|
+
const { lodash } = require('q-koa')
|
|
5
5
|
const getAccessTokenUrl =
|
|
6
6
|
'https://api.weixin.qq.com/cgi-bin/token?grant_type=%s&appid=%s&secret=%s'
|
|
7
7
|
const createQRCodeUrl =
|
package/core/file/utils/index.js
CHANGED