q-koa 12.9.6 → 13.0.1
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
CHANGED
|
@@ -22,7 +22,7 @@ const jwt = require('jsonwebtoken')
|
|
|
22
22
|
const verify = util.promisify(jwt.verify)
|
|
23
23
|
const fsExtra = require('fs-extra')
|
|
24
24
|
const { getObject, getAppConfig } = require('./file/utils')
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
const restc = require('./restc')
|
|
27
27
|
const APP_DIR = 'app'
|
|
28
28
|
const PLUGINS_DIR = 'plugins'
|
|
@@ -472,6 +472,8 @@ class APP {
|
|
|
472
472
|
await this.initModel(appName)
|
|
473
473
|
// const models = Object.keys(this.app[appName].model).join(' / ')
|
|
474
474
|
} catch (e) {
|
|
475
|
+
const { push } = require('./file/plugins/log/service')
|
|
476
|
+
|
|
475
477
|
push({
|
|
476
478
|
appName,
|
|
477
479
|
message: `${appName}数据库连接失败`,
|
|
@@ -773,7 +775,7 @@ class APP {
|
|
|
773
775
|
}
|
|
774
776
|
}
|
|
775
777
|
const start = moment().valueOf()
|
|
776
|
-
for (const fn of ['service'
|
|
778
|
+
for (const fn of ['service']) {
|
|
777
779
|
const cloneTarget = this.app[appName][fn]
|
|
778
780
|
|
|
779
781
|
this.app[appName][fn] = Object.keys(cloneTarget).reduce((a, b) => {
|
|
@@ -1152,64 +1154,57 @@ class APP {
|
|
|
1152
1154
|
|
|
1153
1155
|
if (where) {
|
|
1154
1156
|
if (fn === 'findAndCountAll') {
|
|
1155
|
-
const
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
) {
|
|
1161
|
-
return {
|
|
1162
|
-
$notIn: [Sequelize.literal(item.$notIn)],
|
|
1163
|
-
}
|
|
1157
|
+
const $lt = {
|
|
1158
|
+
check: (param) => typeof param === 'string',
|
|
1159
|
+
result: (param, key) => {
|
|
1160
|
+
return {
|
|
1161
|
+
[key]: Sequelize.literal(param[key]),
|
|
1164
1162
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
if (
|
|
1175
|
-
item.hasOwnProperty('$lt') &&
|
|
1176
|
-
typeof item.$lt === 'string'
|
|
1177
|
-
) {
|
|
1178
|
-
return {
|
|
1179
|
-
$lt: Sequelize.literal(item.$lt),
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
if (
|
|
1184
|
-
item.hasOwnProperty('$lte') &&
|
|
1185
|
-
typeof item.$lte === 'string'
|
|
1186
|
-
) {
|
|
1187
|
-
return {
|
|
1188
|
-
$lte: Sequelize.literal(item.$lte),
|
|
1189
|
-
}
|
|
1163
|
+
},
|
|
1164
|
+
}
|
|
1165
|
+
const $in = {
|
|
1166
|
+
check: (param) => typeof param === 'string',
|
|
1167
|
+
result: (param, key) => {
|
|
1168
|
+
return {
|
|
1169
|
+
[key]: [Sequelize.literal(param[key])],
|
|
1190
1170
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
}
|
|
1171
|
+
},
|
|
1172
|
+
}
|
|
1173
|
+
const $between = {
|
|
1174
|
+
check: (param) => Array.isArray(param),
|
|
1175
|
+
result: (param, key) => {
|
|
1176
|
+
return {
|
|
1177
|
+
[key]: param[key].map(Sequelize.literal),
|
|
1199
1178
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1179
|
+
},
|
|
1180
|
+
}
|
|
1181
|
+
const mapper = {
|
|
1182
|
+
$between,
|
|
1183
|
+
notBetween: $between,
|
|
1184
|
+
$lt,
|
|
1185
|
+
$lte: $lt,
|
|
1186
|
+
$gt: $lt,
|
|
1187
|
+
$gte: $lt,
|
|
1188
|
+
$in,
|
|
1189
|
+
$notIn: $in,
|
|
1190
|
+
}
|
|
1191
|
+
const formatObj = (target) => {
|
|
1192
|
+
for (const key of Object.keys(mapper)) {
|
|
1193
|
+
if (Object.hasOwnProperty.call(target, key)) {
|
|
1194
|
+
if (mapper[key].check(target[key])) {
|
|
1195
|
+
return mapper[key].result(target, key)
|
|
1196
|
+
} else {
|
|
1197
|
+
return target
|
|
1207
1198
|
}
|
|
1199
|
+
} else {
|
|
1200
|
+
continue
|
|
1208
1201
|
}
|
|
1209
|
-
return item
|
|
1210
|
-
} else {
|
|
1211
|
-
return item
|
|
1212
1202
|
}
|
|
1203
|
+
return target
|
|
1204
|
+
}
|
|
1205
|
+
const formatWhere = _.mapValues(where, (item) => {
|
|
1206
|
+
if (!_.isObject(item)) return item
|
|
1207
|
+
return formatObj(item)
|
|
1213
1208
|
})
|
|
1214
1209
|
_where = _.cloneDeep(formatWhere)
|
|
1215
1210
|
} else {
|
|
@@ -413,7 +413,9 @@ exports.initDataWithCache = exports.initData = async (ctx) => {
|
|
|
413
413
|
|
|
414
414
|
const { is_cache } = await appConfig.getObject('base')
|
|
415
415
|
const { includes, excludes = [] } = ctx.request.body
|
|
416
|
-
|
|
416
|
+
if (!includes) {
|
|
417
|
+
return ctx.SUCCESS(null)
|
|
418
|
+
}
|
|
417
419
|
const cacheTarget = JSON.stringify(ctx.request.body)
|
|
418
420
|
|
|
419
421
|
let result = null
|
|
@@ -925,9 +925,12 @@ exports.app_pay = async (ctx) => {
|
|
|
925
925
|
// }
|
|
926
926
|
const appConfig = getConfig(app)
|
|
927
927
|
|
|
928
|
-
const {
|
|
929
|
-
|
|
930
|
-
|
|
928
|
+
const {
|
|
929
|
+
mchId,
|
|
930
|
+
key,
|
|
931
|
+
partner_key,
|
|
932
|
+
appId: appid,
|
|
933
|
+
} = await appConfig.getObject(pay_config)
|
|
931
934
|
|
|
932
935
|
if (!appid) throw new Error(`appId不能存在`)
|
|
933
936
|
|