q-koa 11.8.6 → 11.9.0
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
|
@@ -1099,7 +1099,6 @@ class APP {
|
|
|
1099
1099
|
$in: [Sequelize.literal(item.$in)],
|
|
1100
1100
|
}
|
|
1101
1101
|
}
|
|
1102
|
-
console.log(item.$lt)
|
|
1103
1102
|
if (
|
|
1104
1103
|
item.hasOwnProperty('$lt') &&
|
|
1105
1104
|
typeof item.$lt === 'string'
|
|
@@ -1159,7 +1158,10 @@ class APP {
|
|
|
1159
1158
|
.filter(
|
|
1160
1159
|
(item) =>
|
|
1161
1160
|
(item.where && !item.hasOwnProperty('required')) ||
|
|
1162
|
-
(item.hasOwnProperty('required') && item.required)
|
|
1161
|
+
(item.hasOwnProperty('required') && item.required) ||
|
|
1162
|
+
(item.hasOwnProperty('where') &&
|
|
1163
|
+
item.hasOwnProperty('required') &&
|
|
1164
|
+
!item.required)
|
|
1163
1165
|
)
|
|
1164
1166
|
.map((item) => {
|
|
1165
1167
|
return {
|
|
@@ -1174,6 +1176,7 @@ class APP {
|
|
|
1174
1176
|
},
|
|
1175
1177
|
}
|
|
1176
1178
|
})
|
|
1179
|
+
|
|
1177
1180
|
const { count, rows } = await app[appName].model[controller][
|
|
1178
1181
|
fn
|
|
1179
1182
|
]({
|
|
@@ -1200,7 +1203,10 @@ class APP {
|
|
|
1200
1203
|
(myInclude[j].where &&
|
|
1201
1204
|
!myInclude[j].hasOwnProperty('required')) ||
|
|
1202
1205
|
(myInclude[j].hasOwnProperty('required') &&
|
|
1203
|
-
myInclude[j].required)
|
|
1206
|
+
myInclude[j].required) ||
|
|
1207
|
+
(myInclude[j].hasOwnProperty('where') &&
|
|
1208
|
+
myInclude[j].hasOwnProperty('required') &&
|
|
1209
|
+
!myInclude[j].required)
|
|
1204
1210
|
) {
|
|
1205
1211
|
continue
|
|
1206
1212
|
}
|
|
@@ -1266,7 +1272,10 @@ class APP {
|
|
|
1266
1272
|
(myInclude[j].where &&
|
|
1267
1273
|
!myInclude[j].hasOwnProperty('required')) ||
|
|
1268
1274
|
(myInclude[j].hasOwnProperty('required') &&
|
|
1269
|
-
myInclude[j].required)
|
|
1275
|
+
myInclude[j].required) ||
|
|
1276
|
+
(myInclude[j].hasOwnProperty('where') &&
|
|
1277
|
+
myInclude[j].hasOwnProperty('required') &&
|
|
1278
|
+
!myInclude[j].required)
|
|
1270
1279
|
) {
|
|
1271
1280
|
continue
|
|
1272
1281
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getConfig, lodash } = require('q-koa')
|
|
1
|
+
const { getConfig, lodash, Sequelize } = require('q-koa')
|
|
2
2
|
const formatPostFunction = (str) => `eval(${str})`
|
|
3
3
|
const nodeVm = require('vm')
|
|
4
4
|
const axios = require('axios')
|
|
@@ -198,11 +198,61 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
|
198
198
|
}
|
|
199
199
|
})
|
|
200
200
|
} else {
|
|
201
|
+
const formatData =
|
|
202
|
+
fn === 'findAll' &&
|
|
203
|
+
data &&
|
|
204
|
+
lodash.isObject(data) &&
|
|
205
|
+
data.hasOwnProperty('where')
|
|
206
|
+
? Object.keys(data).reduce((a, b) => {
|
|
207
|
+
return {
|
|
208
|
+
...a,
|
|
209
|
+
...(b === 'where'
|
|
210
|
+
? {
|
|
211
|
+
[b]: Object.keys(data[b]).reduce((_a, _b) => {
|
|
212
|
+
return {
|
|
213
|
+
..._a,
|
|
214
|
+
...(['$gt', '$lt'].some((i) =>
|
|
215
|
+
data[b][_b].hasOwnProperty(i)
|
|
216
|
+
)
|
|
217
|
+
? {
|
|
218
|
+
[_b]: data[b][_b],
|
|
219
|
+
...(typeof data[b][_b].$gt ===
|
|
220
|
+
'string' &&
|
|
221
|
+
data[b][_b].hasOwnProperty('$gt')
|
|
222
|
+
? {
|
|
223
|
+
[_b]: {
|
|
224
|
+
$gt: Sequelize.literal(
|
|
225
|
+
data[b][_b].$gt
|
|
226
|
+
),
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
: {}),
|
|
230
|
+
...(typeof data[b][_b].$lt ===
|
|
231
|
+
'string' &&
|
|
232
|
+
data[b][_b].hasOwnProperty('$lt')
|
|
233
|
+
? {
|
|
234
|
+
[_b]: {
|
|
235
|
+
$lt: Sequelize.literal(
|
|
236
|
+
data[b][_b].$lt
|
|
237
|
+
),
|
|
238
|
+
},
|
|
239
|
+
}
|
|
240
|
+
: {}),
|
|
241
|
+
}
|
|
242
|
+
: { [_b]: data[b][_b] }),
|
|
243
|
+
}
|
|
244
|
+
}, {}),
|
|
245
|
+
}
|
|
246
|
+
: { [b]: data[b] }),
|
|
247
|
+
}
|
|
248
|
+
}, {})
|
|
249
|
+
: data
|
|
250
|
+
// console.log('formatData', data, '-->', formatData)
|
|
201
251
|
return app.model[model][fn]({
|
|
202
252
|
order,
|
|
203
253
|
limit,
|
|
204
254
|
include: myInclude,
|
|
205
|
-
...
|
|
255
|
+
...formatData,
|
|
206
256
|
}).then((result) => {
|
|
207
257
|
const list =
|
|
208
258
|
data && data.omit && Array.isArray(data.omit)
|
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
|
16
16
|
key: 'type',
|
|
17
17
|
},
|
|
18
18
|
],
|
|
19
|
-
excludes: [],
|
|
19
|
+
excludes: ['administrator'],
|
|
20
20
|
limit: 20,
|
|
21
21
|
defaultOrder: [
|
|
22
22
|
{ sort: 'ascending', type: 'status' },
|
|
@@ -27,5 +27,9 @@ module.exports = {
|
|
|
27
27
|
excludeAuth: [],
|
|
28
28
|
initList: [],
|
|
29
29
|
is_split: false,
|
|
30
|
-
show_virtual:
|
|
30
|
+
show_virtual: true,
|
|
31
|
+
modelUpsert: {
|
|
32
|
+
administrator:
|
|
33
|
+
'(target, getName, user_info) => target.administrator || user_info.name',
|
|
34
|
+
},
|
|
31
35
|
}
|
|
@@ -18,6 +18,9 @@ exports.desc = {
|
|
|
18
18
|
defaultValue: '',
|
|
19
19
|
sortOrder: 2,
|
|
20
20
|
mock: () => Random.csentence(),
|
|
21
|
+
extra: {
|
|
22
|
+
tableWidth: 0,
|
|
23
|
+
},
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
exports.image_list = {
|
|
@@ -67,3 +70,23 @@ exports.important_rate = {
|
|
|
67
70
|
tableWidth: 180,
|
|
68
71
|
},
|
|
69
72
|
}
|
|
73
|
+
|
|
74
|
+
exports.administrator = {
|
|
75
|
+
type: Sequelize.STRING,
|
|
76
|
+
comment: '管理员',
|
|
77
|
+
allowNull: false,
|
|
78
|
+
is_mock: true,
|
|
79
|
+
defaultValue: '',
|
|
80
|
+
sortOrder: 7,
|
|
81
|
+
mock: () => Random.ctitle(),
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.from = {
|
|
85
|
+
type: Sequelize.VIRTUAL,
|
|
86
|
+
comment: '来自管理员',
|
|
87
|
+
sortOrder: 8,
|
|
88
|
+
get: function () {
|
|
89
|
+
const administrator = this.getDataValue('administrator')
|
|
90
|
+
return administrator
|
|
91
|
+
},
|
|
92
|
+
}
|