q-koa 7.7.2 → 7.7.7
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/app.js +13 -9
- 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 +9 -5
- 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 +8 -5
- package/core/file/plugins/model/model.js +1 -1
- package/core/file/plugins/model/service.js +11 -11
- 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 +5 -8
- 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 +2 -2
- package/core/file/plugins/weixin/service.js +4 -3
- 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 +3 -3
- package/core/file/services/weixin.js +21 -12
- package/core/file/services/weixinMP.js +3 -2
- package/core/file/utils/index.js +1 -1
- package/core/restc/lib/index.js +4 -1
- package/package.json +2 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const { Validator,getAppByCtx } = require('
|
|
2
|
-
|
|
1
|
+
const { Validator, getAppByCtx } = require('q-koa')
|
|
3
2
|
|
|
4
3
|
exports.bulkUpdate = async (ctx) => {
|
|
5
4
|
const params = {
|
|
@@ -8,22 +7,17 @@ exports.bulkUpdate = async (ctx) => {
|
|
|
8
7
|
required: true,
|
|
9
8
|
message: '请输入list',
|
|
10
9
|
},
|
|
11
|
-
}
|
|
12
|
-
await new Validator(params).validate(ctx.request.body)
|
|
13
|
-
}
|
|
10
|
+
}
|
|
11
|
+
await new Validator(params).validate(ctx.request.body)
|
|
12
|
+
}
|
|
14
13
|
|
|
15
|
-
exports.upsert = async ctx => {
|
|
16
|
-
const {
|
|
17
|
-
app
|
|
18
|
-
} = getAppByCtx(ctx);
|
|
14
|
+
exports.upsert = async (ctx) => {
|
|
15
|
+
const { app } = getAppByCtx(ctx)
|
|
19
16
|
|
|
20
|
-
const {
|
|
21
|
-
id,
|
|
22
|
-
parent_id
|
|
23
|
-
} = ctx.request.body
|
|
17
|
+
const { id, parent_id } = ctx.request.body
|
|
24
18
|
|
|
25
19
|
if (id && parent_id && id === parent_id) throw new Error('不能分类到自己')
|
|
26
|
-
}
|
|
20
|
+
}
|
|
27
21
|
|
|
28
22
|
exports.copyOther = async (ctx) => {
|
|
29
23
|
const params = {
|
|
@@ -32,11 +26,11 @@ exports.copyOther = async (ctx) => {
|
|
|
32
26
|
required: true,
|
|
33
27
|
message: '请输入type, 需要复制哪个code',
|
|
34
28
|
},
|
|
35
|
-
source:{
|
|
29
|
+
source: {
|
|
36
30
|
type: 'string',
|
|
37
31
|
required: true,
|
|
38
32
|
message: '请输入source, 需要从哪个项目复制哪个(记得开启)',
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
await new Validator(params).validate(ctx.request.body)
|
|
42
|
-
}
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
await new Validator(params).validate(ctx.request.body)
|
|
36
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
+
const fsPromise = require('fs/promises')
|
|
3
4
|
const { VM } = require('vm2')
|
|
4
5
|
const axios = require('axios')
|
|
5
6
|
const cheerio = require('cheerio')
|
|
6
|
-
const {
|
|
7
|
-
lodash,
|
|
8
|
-
getAppByCtx,
|
|
9
|
-
getConfig,
|
|
10
|
-
Sequelize,
|
|
11
|
-
} = require('multiple-quick-koa')
|
|
7
|
+
const { lodash, getAppByCtx, getConfig, Sequelize } = require('q-koa')
|
|
12
8
|
|
|
13
9
|
exports.initModel = async (ctx) => {
|
|
14
10
|
const { app } = getAppByCtx(ctx)
|
|
@@ -62,7 +58,8 @@ exports.showTables = async (ctx) => {
|
|
|
62
58
|
`${process.cwd()}/app/${appName}/plugins`
|
|
63
59
|
)
|
|
64
60
|
let aliasModelList = []
|
|
65
|
-
|
|
61
|
+
const allList = await fsPromise.readdir(pluginDir)
|
|
62
|
+
allList.forEach((folder) => {
|
|
66
63
|
const isFolder = fs.lstatSync(path.resolve(pluginDir, folder)).isDirectory()
|
|
67
64
|
const hasConfig = fs.existsSync(
|
|
68
65
|
path.resolve(
|
|
@@ -254,7 +251,7 @@ exports.getImage = async (ctx) => {
|
|
|
254
251
|
__dirname,
|
|
255
252
|
`${process.cwd()}/public/upload`
|
|
256
253
|
)}`
|
|
257
|
-
const files =
|
|
254
|
+
const files = await fsPromise.readdir(targetDir)
|
|
258
255
|
const images = files.filter((file) =>
|
|
259
256
|
/\w(\.gif|\.jpeg|\.png|\.jpg|\.bmp)/i.test(file)
|
|
260
257
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Validator, getAppByCtx } = require('
|
|
1
|
+
const { Validator, getAppByCtx } = require('q-koa')
|
|
2
2
|
|
|
3
3
|
exports.initModel = async (ctx) => {
|
|
4
4
|
const params = {
|
|
@@ -7,34 +7,40 @@ exports.initModel = async (ctx) => {
|
|
|
7
7
|
required: true,
|
|
8
8
|
message: '请输入model',
|
|
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.showAllSchemas = async (ctx) => {
|
|
15
|
-
const {app,appName} = getAppByCtx(ctx)
|
|
15
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
16
16
|
|
|
17
17
|
const params = {
|
|
18
18
|
model: {
|
|
19
19
|
type: 'string',
|
|
20
20
|
required: true,
|
|
21
21
|
message: '请输入model',
|
|
22
|
-
validator: (rule, value) =>
|
|
22
|
+
validator: (rule, value) =>
|
|
23
|
+
app[appName].model && app[appName].model[value]
|
|
24
|
+
? Promise.resolve()
|
|
25
|
+
: Promise.reject('没有这个模型'),
|
|
23
26
|
},
|
|
24
|
-
}
|
|
25
|
-
await new Validator(params).validate(ctx.request.body)
|
|
26
|
-
}
|
|
27
|
+
}
|
|
28
|
+
await new Validator(params).validate(ctx.request.body)
|
|
29
|
+
}
|
|
27
30
|
|
|
28
31
|
exports.dropModel = async (ctx) => {
|
|
29
|
-
const {app,appName} = getAppByCtx(ctx)
|
|
32
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
30
33
|
|
|
31
34
|
const params = {
|
|
32
35
|
model: {
|
|
33
36
|
type: 'string',
|
|
34
37
|
required: true,
|
|
35
38
|
message: '请输入model',
|
|
36
|
-
validator: (rule, value) =>
|
|
39
|
+
validator: (rule, value) =>
|
|
40
|
+
app[appName].model && app[appName].model[value]
|
|
41
|
+
? Promise.resolve()
|
|
42
|
+
: Promise.reject('没有这个模型'),
|
|
37
43
|
},
|
|
38
|
-
}
|
|
39
|
-
await new Validator(params).validate(ctx.request.body)
|
|
40
|
-
}
|
|
44
|
+
}
|
|
45
|
+
await new Validator(params).validate(ctx.request.body)
|
|
46
|
+
}
|
|
@@ -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,9 +1,9 @@
|
|
|
1
|
-
const { lodash, getAppByCtx, getConfig } = require('
|
|
1
|
+
const { lodash, getAppByCtx, getConfig } = require('q-koa')
|
|
2
2
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const axios = require('axios')
|
|
5
5
|
const OAuth = require('wechat-oauth')
|
|
6
|
-
const WXPay = require('weixin-pay')
|
|
6
|
+
const WXPay = require('weixin-pay-fork')
|
|
7
7
|
const WeixinPay = require('../../services/weixinPay')
|
|
8
8
|
const WeixinMp = require('../../services/weixinMP')
|
|
9
9
|
const Weixin = require('../../services/weixin')
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
const { getAppByCtx, getConfig } = require('
|
|
1
|
+
const { getAppByCtx, getConfig } = require('q-koa')
|
|
2
2
|
const { Pay } = require('@sigodenjs/wechatpay')
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
const path = require('path')
|
|
5
|
+
const fsPromise = require('fs/promises')
|
|
5
6
|
|
|
6
7
|
exports.refund = async ({
|
|
7
8
|
ctx,
|
|
@@ -21,7 +22,7 @@ exports.refund = async ({
|
|
|
21
22
|
appId: appId,
|
|
22
23
|
mchId: mchId,
|
|
23
24
|
key: key, // 微信商户平台API密钥,
|
|
24
|
-
pfx:
|
|
25
|
+
pfx: await fsPromise.readFile(
|
|
25
26
|
path.resolve(
|
|
26
27
|
__dirname,
|
|
27
28
|
`${process.cwd()}/app/${appName}/plugins/weixin/apiclient_cert.p12`
|
|
@@ -71,7 +72,7 @@ exports.cash = async ({ ctx, id, user_id, number }) => {
|
|
|
71
72
|
appId: appId,
|
|
72
73
|
mchId: mchId,
|
|
73
74
|
key: key, // 微信商户平台API密钥,
|
|
74
|
-
pfx:
|
|
75
|
+
pfx: await fsPromise.readFile(
|
|
75
76
|
path.resolve(
|
|
76
77
|
__dirname,
|
|
77
78
|
`${process.cwd()}/app/${appName}/plugins/weixin/apiclient_cert.p12`
|