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,38 +1,43 @@
|
|
|
1
|
-
const {
|
|
2
|
-
getAppByCtx,
|
|
3
|
-
getConfig,
|
|
4
|
-
} = require('multiple-quick-koa');
|
|
1
|
+
const { getAppByCtx, getConfig } = require('q-koa')
|
|
5
2
|
|
|
6
3
|
exports.destroy = async (ctx) => {
|
|
7
|
-
const {
|
|
8
|
-
app,
|
|
9
|
-
} = getAppByCtx(ctx);
|
|
4
|
+
const { app } = getAppByCtx(ctx)
|
|
10
5
|
|
|
11
|
-
const {
|
|
12
|
-
id,
|
|
13
|
-
} = ctx.request.body;
|
|
14
|
-
|
|
15
|
-
app.model.mp_user && app.model.mp_user.destroy({
|
|
16
|
-
where: {
|
|
17
|
-
user_id: id,
|
|
18
|
-
},
|
|
19
|
-
}).then(() => {
|
|
20
|
-
console.log(`删除${id}`);
|
|
21
|
-
}).catch(console.log);
|
|
6
|
+
const { id } = ctx.request.body
|
|
22
7
|
|
|
23
|
-
app.model.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
app.model.mp_user &&
|
|
9
|
+
app.model.mp_user
|
|
10
|
+
.destroy({
|
|
11
|
+
where: {
|
|
12
|
+
user_id: id,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
.then(() => {
|
|
16
|
+
console.log(`删除${id}`)
|
|
17
|
+
})
|
|
18
|
+
.catch(console.log)
|
|
30
19
|
|
|
31
|
-
app.model.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
app.model.h5_user &&
|
|
21
|
+
app.model.h5_user
|
|
22
|
+
.destroy({
|
|
23
|
+
where: {
|
|
24
|
+
user_id: id,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
.then(() => {
|
|
28
|
+
console.log(`删除${id}`)
|
|
29
|
+
})
|
|
30
|
+
.catch(console.log)
|
|
31
|
+
|
|
32
|
+
app.model.toutiao_user &&
|
|
33
|
+
app.model.toutiao_user
|
|
34
|
+
.destroy({
|
|
35
|
+
where: {
|
|
36
|
+
user_id: id,
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
.then(() => {
|
|
40
|
+
console.log(`删除${id}`)
|
|
41
|
+
})
|
|
42
|
+
.catch(console.log)
|
|
43
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { Sequelize, Random } = require('
|
|
2
|
-
const md5 = require('js-md5')
|
|
1
|
+
const { Sequelize, Random } = require('q-koa')
|
|
2
|
+
const md5 = require('js-md5')
|
|
3
3
|
|
|
4
4
|
exports.nick_name = {
|
|
5
5
|
type: Sequelize.STRING,
|
|
@@ -8,7 +8,7 @@ exports.nick_name = {
|
|
|
8
8
|
is_mock: false,
|
|
9
9
|
defaultValue: '',
|
|
10
10
|
sortOrder: 1,
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
exports.name = {
|
|
13
13
|
type: Sequelize.STRING,
|
|
14
14
|
comment: '名字',
|
|
@@ -18,12 +18,18 @@ exports.name = {
|
|
|
18
18
|
sortOrder: 2,
|
|
19
19
|
mock: () => Random.word(5),
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return (
|
|
22
|
+
this.getDataValue('nick_name') ||
|
|
23
|
+
(this.getDataValue('mp_user') &&
|
|
24
|
+
this.getDataValue('mp_user').nick_name) ||
|
|
25
|
+
(this.getDataValue('h5_user') &&
|
|
26
|
+
this.getDataValue('h5_user').nick_name) ||
|
|
27
|
+
(this.getDataValue('toutiao_user') &&
|
|
28
|
+
this.getDataValue('toutiao_user').nick_name) ||
|
|
29
|
+
'匿名用户'
|
|
30
|
+
)
|
|
25
31
|
},
|
|
26
|
-
}
|
|
32
|
+
}
|
|
27
33
|
|
|
28
34
|
exports.image = {
|
|
29
35
|
type: Sequelize.VIRTUAL,
|
|
@@ -33,20 +39,25 @@ exports.image = {
|
|
|
33
39
|
defaultValue: '',
|
|
34
40
|
sortOrder: 3,
|
|
35
41
|
get: function () {
|
|
36
|
-
return
|
|
42
|
+
return (
|
|
43
|
+
this.getDataValue('avatar') ||
|
|
44
|
+
(this.getDataValue('mp_user') && this.getDataValue('mp_user').avatar) ||
|
|
37
45
|
(this.getDataValue('h5_user') && this.getDataValue('h5_user').avatar) ||
|
|
38
|
-
(this.getDataValue('toutiao_user') &&
|
|
46
|
+
(this.getDataValue('toutiao_user') &&
|
|
47
|
+
this.getDataValue('toutiao_user').avatar) ||
|
|
39
48
|
'//p0.meituan.net/codeman/bc1b8f0172cf718719edfb130ba171912425.jpg@120w_120h_1c_1e'
|
|
49
|
+
)
|
|
40
50
|
},
|
|
41
|
-
}
|
|
51
|
+
}
|
|
42
52
|
|
|
43
53
|
exports.avatar = {
|
|
44
54
|
type: Sequelize.STRING,
|
|
45
55
|
comment: '头像',
|
|
46
56
|
allowNull: false,
|
|
47
|
-
defaultValue:
|
|
57
|
+
defaultValue:
|
|
58
|
+
'//p0.meituan.net/codeman/bc1b8f0172cf718719edfb130ba171912425.jpg@120w_120h_1c_1e',
|
|
48
59
|
mock: () => Random.image('100x100', Random.color(), Random.cword()),
|
|
49
|
-
}
|
|
60
|
+
}
|
|
50
61
|
|
|
51
62
|
exports.code = {
|
|
52
63
|
type: Sequelize.STRING(6),
|
|
@@ -54,14 +65,14 @@ exports.code = {
|
|
|
54
65
|
comment: '验证码',
|
|
55
66
|
defaultValue: '',
|
|
56
67
|
mock: () => Random.string('number', 4),
|
|
57
|
-
}
|
|
68
|
+
}
|
|
58
69
|
|
|
59
70
|
exports.sex_id = {
|
|
60
71
|
type: Sequelize.INTEGER(11),
|
|
61
72
|
allowNull: false,
|
|
62
73
|
defaultValue: 4,
|
|
63
74
|
comment: '性别',
|
|
64
|
-
}
|
|
75
|
+
}
|
|
65
76
|
|
|
66
77
|
exports.password = {
|
|
67
78
|
type: Sequelize.STRING(),
|
|
@@ -70,7 +81,7 @@ exports.password = {
|
|
|
70
81
|
defaultValue: '7b17d87eb787c51b4da25ec1bed26c8d',
|
|
71
82
|
set(value) {
|
|
72
83
|
this.setDataValue('password', md5(value))
|
|
73
|
-
}
|
|
84
|
+
},
|
|
74
85
|
// validate: {
|
|
75
86
|
// notNull: {
|
|
76
87
|
// msg: '密码不允许为空',
|
|
@@ -79,7 +90,7 @@ exports.password = {
|
|
|
79
90
|
// msg: '密码不允许为空',
|
|
80
91
|
// },
|
|
81
92
|
// },
|
|
82
|
-
}
|
|
93
|
+
}
|
|
83
94
|
|
|
84
95
|
exports.mobile = {
|
|
85
96
|
type: Sequelize.STRING(),
|
|
@@ -93,4 +104,4 @@ exports.mobile = {
|
|
|
93
104
|
// },
|
|
94
105
|
// },
|
|
95
106
|
mock: () => Random.natural(13000000000, 19999999999),
|
|
96
|
-
}
|
|
107
|
+
}
|
|
@@ -1,71 +1,86 @@
|
|
|
1
|
-
const axios = require('axios')
|
|
2
|
-
const APP = require('
|
|
3
|
-
const APP_CONFIG = require('../../config')
|
|
4
|
-
const config = require('./config')
|
|
1
|
+
const axios = require('axios')
|
|
2
|
+
const APP = require('q-koa')
|
|
3
|
+
const APP_CONFIG = require('../../config')
|
|
4
|
+
const config = require('./config')
|
|
5
5
|
|
|
6
|
-
const modelName = __dirname.split('/').reverse()[0]
|
|
6
|
+
const modelName = __dirname.split('/').reverse()[0]
|
|
7
7
|
const service = axios.create({
|
|
8
8
|
baseURL: `http://localhost:${APP_CONFIG.port}/${modelName}`,
|
|
9
|
-
})
|
|
10
|
-
service.interceptors.request.use((config) => {
|
|
9
|
+
})
|
|
10
|
+
service.interceptors.request.use((config) => {
|
|
11
|
+
config.headers['Client-Type'] = 2
|
|
12
|
+
return config
|
|
13
|
+
})
|
|
11
14
|
|
|
12
|
-
service.interceptors.response.use(
|
|
15
|
+
service.interceptors.response.use(
|
|
16
|
+
(response) => response.data,
|
|
17
|
+
(error) => Promise.reject(error)
|
|
18
|
+
)
|
|
13
19
|
|
|
14
|
-
const sleep = time =>
|
|
20
|
+
const sleep = (time) =>
|
|
21
|
+
new Promise((resolve) => setTimeout(resolve, time * 1000))
|
|
15
22
|
|
|
16
23
|
describe(`${config.name}/${modelName}`, () => {
|
|
17
24
|
beforeAll(async () => {
|
|
18
25
|
try {
|
|
19
|
-
await axios.post('/')
|
|
26
|
+
await axios.post('/')
|
|
20
27
|
} catch (e) {
|
|
21
|
-
console.log('正在启动服务器')
|
|
22
|
-
const app = new APP(APP_CONFIG)
|
|
23
|
-
await app.start()
|
|
28
|
+
console.log('正在启动服务器')
|
|
29
|
+
const app = new APP(APP_CONFIG)
|
|
30
|
+
await app.start()
|
|
24
31
|
}
|
|
25
|
-
})
|
|
32
|
+
})
|
|
26
33
|
|
|
27
34
|
test('错误登录', async () => {
|
|
28
35
|
const res = await service.post('login', {
|
|
29
36
|
name: 'chenlin1',
|
|
30
37
|
password: 'sugar23',
|
|
31
|
-
})
|
|
32
|
-
expect(res.code).toBe(500)
|
|
33
|
-
})
|
|
38
|
+
})
|
|
39
|
+
expect(res.code).toBe(500)
|
|
40
|
+
})
|
|
34
41
|
|
|
35
42
|
test('正确登录', async () => {
|
|
36
43
|
const res = await service.post('login', {
|
|
37
44
|
name: 'chenlin',
|
|
38
45
|
password: 'sugar23',
|
|
39
|
-
})
|
|
40
|
-
expect(res.code).toBe(200)
|
|
41
|
-
})
|
|
46
|
+
})
|
|
47
|
+
expect(res.code).toBe(200)
|
|
48
|
+
})
|
|
42
49
|
|
|
43
50
|
test('获取token', async () => {
|
|
44
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
data: { token },
|
|
53
|
+
} = await service.post('login', {
|
|
45
54
|
name: 'chenlin',
|
|
46
55
|
password: 'sugar23',
|
|
47
|
-
})
|
|
48
|
-
expect(Boolean(token)).toBe(true)
|
|
49
|
-
})
|
|
56
|
+
})
|
|
57
|
+
expect(Boolean(token)).toBe(true)
|
|
58
|
+
})
|
|
50
59
|
|
|
51
60
|
test('没有token信息', async () => {
|
|
52
|
-
const res = await service.post('getInfo', {})
|
|
53
|
-
expect(res.code).toBe(401)
|
|
54
|
-
})
|
|
61
|
+
const res = await service.post('getInfo', {})
|
|
62
|
+
expect(res.code).toBe(401)
|
|
63
|
+
})
|
|
55
64
|
|
|
56
65
|
test('获取用户信息', async () => {
|
|
57
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
data: { token },
|
|
68
|
+
} = await service.post('login', {
|
|
58
69
|
name: 'chenlin',
|
|
59
70
|
password: 'sugar23',
|
|
60
|
-
})
|
|
71
|
+
})
|
|
61
72
|
|
|
62
|
-
const res = await service.post(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
const res = await service.post(
|
|
74
|
+
'getInfo',
|
|
75
|
+
{},
|
|
76
|
+
{
|
|
77
|
+
headers: {
|
|
78
|
+
'Client-Type': 2,
|
|
79
|
+
'X-Token': token,
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
)
|
|
68
83
|
|
|
69
|
-
expect(res.code).toBe(200)
|
|
70
|
-
})
|
|
71
|
-
})
|
|
84
|
+
expect(res.code).toBe(200)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Validator } = require('
|
|
1
|
+
const { Validator } = require('q-koa')
|
|
2
2
|
|
|
3
3
|
exports.login = async (ctx) => {
|
|
4
4
|
const params = {
|
|
@@ -12,10 +12,9 @@ exports.login = async (ctx) => {
|
|
|
12
12
|
required: true,
|
|
13
13
|
message: '请输入密码',
|
|
14
14
|
},
|
|
15
|
-
}
|
|
16
|
-
await new Validator(params).validate(ctx.request.body)
|
|
17
|
-
}
|
|
18
|
-
|
|
15
|
+
}
|
|
16
|
+
await new Validator(params).validate(ctx.request.body)
|
|
17
|
+
}
|
|
19
18
|
|
|
20
19
|
exports.register = async (ctx) => {
|
|
21
20
|
const params = {
|
|
@@ -39,6 +38,6 @@ exports.register = async (ctx) => {
|
|
|
39
38
|
required: true,
|
|
40
39
|
message: '请输入昵称',
|
|
41
40
|
},
|
|
42
|
-
}
|
|
43
|
-
await new Validator(params).validate(ctx.request.body)
|
|
44
|
-
}
|
|
41
|
+
}
|
|
42
|
+
await new Validator(params).validate(ctx.request.body)
|
|
43
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
const qqVideo = require('../../services/qqVideo')
|
|
2
|
-
const { getAppByCtx } = require('
|
|
2
|
+
const { getAppByCtx } = require('q-koa')
|
|
3
3
|
|
|
4
|
-
exports.qq = async ctx => {
|
|
4
|
+
exports.qq = async (ctx) => {
|
|
5
5
|
const { app, appName } = getAppByCtx(ctx)
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
vid
|
|
9
|
-
} = ctx.request.body
|
|
7
|
+
const { vid } = ctx.request.body
|
|
10
8
|
|
|
11
9
|
const video = await qqVideo(vid)
|
|
12
10
|
// if (true) throw new Error('账号密码错误');
|
|
13
11
|
|
|
14
12
|
return ctx.SUCCESS(video)
|
|
15
|
-
}
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Validator } = require('
|
|
1
|
+
const { Validator } = require('q-koa')
|
|
2
2
|
|
|
3
3
|
exports.qq = async (ctx) => {
|
|
4
4
|
const params = {
|
|
@@ -7,6 +7,6 @@ exports.qq = async (ctx) => {
|
|
|
7
7
|
required: true,
|
|
8
8
|
message: '请输入腾讯vid',
|
|
9
9
|
},
|
|
10
|
-
}
|
|
11
|
-
await new Validator(params).validate(ctx.request.body)
|
|
12
|
-
}
|
|
10
|
+
}
|
|
11
|
+
await new Validator(params).validate(ctx.request.body)
|
|
12
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Validator } = require('
|
|
1
|
+
const { Validator } = require('q-koa')
|
|
2
2
|
|
|
3
3
|
exports.getConfig = async (ctx) => {
|
|
4
4
|
const params = {
|
|
@@ -7,27 +7,27 @@ exports.getConfig = async (ctx) => {
|
|
|
7
7
|
required: true,
|
|
8
8
|
message: '请输入url',
|
|
9
9
|
},
|
|
10
|
-
}
|
|
11
|
-
await new Validator(params).validate(ctx.request.body)
|
|
12
|
-
}
|
|
10
|
+
}
|
|
11
|
+
await new Validator(params).validate(ctx.request.body)
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
exports.h5_pay = async (ctx) => {
|
|
15
15
|
/**
|
|
16
16
|
* 判断微信
|
|
17
17
|
*/
|
|
18
|
-
const userAgent = ctx.userAgent._agent.source
|
|
19
|
-
const isWeixin = /MicroMessenger/i.test(userAgent)
|
|
20
|
-
if (isWeixin) throw new Error('请用手机浏览器打开')
|
|
21
|
-
}
|
|
18
|
+
const userAgent = ctx.userAgent._agent.source
|
|
19
|
+
const isWeixin = /MicroMessenger/i.test(userAgent)
|
|
20
|
+
if (isWeixin) throw new Error('请用手机浏览器打开')
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
exports.wx_pay = async (ctx) => {
|
|
24
24
|
/**
|
|
25
25
|
* 判断微信
|
|
26
26
|
*/
|
|
27
|
-
const userAgent = ctx.userAgent._agent.source
|
|
28
|
-
const isWeixin = /MicroMessenger/i.test(userAgent)
|
|
29
|
-
if (!isWeixin) throw new Error('请在微信里打开')
|
|
30
|
-
}
|
|
27
|
+
const userAgent = ctx.userAgent._agent.source
|
|
28
|
+
const isWeixin = /MicroMessenger/i.test(userAgent)
|
|
29
|
+
if (!isWeixin) throw new Error('请在微信里打开')
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
exports.pay = async (ctx) => {
|
|
33
33
|
const params = {
|
|
@@ -46,9 +46,9 @@ exports.pay = async (ctx) => {
|
|
|
46
46
|
required: 1,
|
|
47
47
|
message: '请输入支付金额',
|
|
48
48
|
},
|
|
49
|
-
}
|
|
50
|
-
await new Validator(params).validate(ctx.request.body)
|
|
51
|
-
}
|
|
49
|
+
}
|
|
50
|
+
await new Validator(params).validate(ctx.request.body)
|
|
51
|
+
}
|
|
52
52
|
|
|
53
53
|
exports.mp_login = async (ctx) => {
|
|
54
54
|
const params = {
|
|
@@ -57,10 +57,9 @@ exports.mp_login = async (ctx) => {
|
|
|
57
57
|
required: true,
|
|
58
58
|
message: '需要code登录',
|
|
59
59
|
},
|
|
60
|
-
}
|
|
61
|
-
await new Validator(params).validate(ctx.request.body)
|
|
62
|
-
}
|
|
63
|
-
|
|
60
|
+
}
|
|
61
|
+
await new Validator(params).validate(ctx.request.body)
|
|
62
|
+
}
|
|
64
63
|
|
|
65
64
|
exports.qr_code = async (ctx) => {
|
|
66
65
|
const params = {
|
|
@@ -79,10 +78,9 @@ exports.qr_code = async (ctx) => {
|
|
|
79
78
|
required: false,
|
|
80
79
|
message: 'scene 参数 object',
|
|
81
80
|
},
|
|
82
|
-
}
|
|
83
|
-
await new Validator(params).validate(ctx.request.body)
|
|
84
|
-
}
|
|
85
|
-
|
|
81
|
+
}
|
|
82
|
+
await new Validator(params).validate(ctx.request.body)
|
|
83
|
+
}
|
|
86
84
|
|
|
87
85
|
exports.sendMessage = async (ctx) => {
|
|
88
86
|
const params = {
|
|
@@ -99,13 +97,14 @@ exports.sendMessage = async (ctx) => {
|
|
|
99
97
|
data: {
|
|
100
98
|
type: 'object',
|
|
101
99
|
required: true,
|
|
102
|
-
message:
|
|
100
|
+
message:
|
|
101
|
+
"data | {name1:{value:'苏晓光'},number2:{value:'32323'},thing5:{value:'xxx'}}",
|
|
103
102
|
},
|
|
104
103
|
page: {
|
|
105
104
|
type: 'string',
|
|
106
105
|
required: false,
|
|
107
106
|
message: '请输入页面链接:pages/index/index',
|
|
108
107
|
},
|
|
109
|
-
}
|
|
110
|
-
await new Validator(params).validate(ctx.request.body)
|
|
111
|
-
}
|
|
108
|
+
}
|
|
109
|
+
await new Validator(params).validate(ctx.request.body)
|
|
110
|
+
}
|
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
const Core = require('@alicloud/pop-core')
|
|
2
|
-
const {
|
|
3
|
-
lodash
|
|
4
|
-
} = require('multiple-quick-koa')
|
|
1
|
+
const Core = require('@alicloud/pop-core')
|
|
2
|
+
const { lodash } = require('q-koa')
|
|
5
3
|
module.exports = class Sms {
|
|
6
|
-
constructor
|
|
4
|
+
constructor(config) {
|
|
7
5
|
this.config = {
|
|
8
6
|
accessKeyId: config.accessKeyId, // 开发者账号id
|
|
9
7
|
accessKeySecret: config.accessKeySecret, // 开发者token
|
|
10
8
|
SignName: config.SignName, // 应用id
|
|
11
|
-
param: Array.from(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
param: Array.from(
|
|
10
|
+
{
|
|
11
|
+
length: config.number || 4,
|
|
12
|
+
},
|
|
13
|
+
() => lodash.random(0, 9)
|
|
14
|
+
).join(''),
|
|
15
|
+
}
|
|
15
16
|
this.client = new Core({
|
|
16
17
|
accessKeyId: this.config.accessKeyId,
|
|
17
18
|
accessKeySecret: this.config.accessKeySecret,
|
|
18
19
|
endpoint: 'https://dysmsapi.aliyuncs.com',
|
|
19
|
-
apiVersion: '2017-05-25'
|
|
20
|
-
})
|
|
20
|
+
apiVersion: '2017-05-25',
|
|
21
|
+
})
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
async send
|
|
24
|
-
mobile,
|
|
25
|
-
TemplateCode,
|
|
26
|
-
TemplateParam
|
|
27
|
-
}) {
|
|
24
|
+
async send({ mobile, TemplateCode, TemplateParam }) {
|
|
28
25
|
// if(!mobile) throw new Error('请输入手机号码')
|
|
29
|
-
const result = await this.client.request(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
const result = await this.client.request(
|
|
27
|
+
'SendSms',
|
|
28
|
+
{
|
|
29
|
+
PhoneNumbers: mobile,
|
|
30
|
+
SignName: this.config.SignName,
|
|
31
|
+
TemplateCode,
|
|
32
|
+
TemplateParam: JSON.stringify({
|
|
33
|
+
code: this.config.param,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
method: 'POST',
|
|
38
|
+
}
|
|
39
|
+
)
|
|
39
40
|
return result
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
getCode
|
|
43
|
+
getCode() {
|
|
43
44
|
return this.config.param
|
|
44
45
|
}
|
|
45
|
-
}
|
|
46
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const axios = require('axios')
|
|
2
|
-
const { lodash } = require('
|
|
2
|
+
const { lodash } = require('q-koa')
|
|
3
3
|
|
|
4
4
|
const queryFn = (obj) => {
|
|
5
5
|
const query = Object.keys(obj)
|
|
@@ -10,7 +10,7 @@ const queryFn = (obj) => {
|
|
|
10
10
|
return query.replace('&', '?')
|
|
11
11
|
}
|
|
12
12
|
module.exports = class Singleton {
|
|
13
|
-
constructor
|
|
13
|
+
constructor(key) {
|
|
14
14
|
this.key = key
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -26,7 +26,7 @@ module.exports = class Singleton {
|
|
|
26
26
|
return Singleton.instance
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
async geo
|
|
29
|
+
async geo({ address }) {
|
|
30
30
|
if (!this.key) throw new Error('没有key')
|
|
31
31
|
|
|
32
32
|
const obj = {
|
|
@@ -43,7 +43,7 @@ module.exports = class Singleton {
|
|
|
43
43
|
return data.geocodes
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async regeo
|
|
46
|
+
async regeo({ longitude, latitude }) {
|
|
47
47
|
if (!this.key) throw new Error('没有key')
|
|
48
48
|
|
|
49
49
|
const obj = {
|
|
@@ -60,7 +60,7 @@ module.exports = class Singleton {
|
|
|
60
60
|
return data
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
async getDistrict
|
|
63
|
+
async getDistrict({
|
|
64
64
|
keywords,
|
|
65
65
|
subdistrict,
|
|
66
66
|
page,
|
|
@@ -89,7 +89,7 @@ module.exports = class Singleton {
|
|
|
89
89
|
return data
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
getConfig
|
|
92
|
+
getConfig() {
|
|
93
93
|
return this.key
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const util = require('util')
|
|
2
2
|
const axios = require('axios')
|
|
3
|
-
const { lodash } = require('
|
|
3
|
+
const { lodash } = require('q-koa')
|
|
4
4
|
|
|
5
5
|
const commonTokenUrl =
|
|
6
6
|
'https://open.douyin.com/oauth/client_token/?client_key=%s&client_secret=%s&grant_type=client_credential'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const axios = require('axios')
|
|
2
|
-
const { lodash } = require('
|
|
2
|
+
const { lodash } = require('q-koa')
|
|
3
3
|
const send_url = 'http://wuliu.market.alicloudapi.com/kdi'
|
|
4
4
|
module.exports = class Singleton {
|
|
5
|
-
constructor
|
|
5
|
+
constructor(config) {
|
|
6
6
|
this.config = {
|
|
7
7
|
app_code: config.app_code,
|
|
8
8
|
}
|
|
@@ -20,7 +20,7 @@ module.exports = class Singleton {
|
|
|
20
20
|
return Singleton.instance
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async send
|
|
23
|
+
async send({ no }) {
|
|
24
24
|
const result = await axios({
|
|
25
25
|
method: 'GET',
|
|
26
26
|
url: `${send_url}?no=${no}`,
|
|
@@ -31,7 +31,7 @@ module.exports = class Singleton {
|
|
|
31
31
|
return result.result
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
getConfig
|
|
34
|
+
getConfig() {
|
|
35
35
|
return this.config
|
|
36
36
|
}
|
|
37
37
|
}
|