q-koa 11.8.5 → 11.8.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 CHANGED
@@ -1099,6 +1099,23 @@ class APP {
1099
1099
  $in: [Sequelize.literal(item.$in)],
1100
1100
  }
1101
1101
  }
1102
+ if (
1103
+ item.hasOwnProperty('$lt') &&
1104
+ typeof item.$lt === 'string'
1105
+ ) {
1106
+ return {
1107
+ $lt: Sequelize.literal(item.$lt),
1108
+ }
1109
+ }
1110
+
1111
+ if (
1112
+ item.hasOwnProperty('$gt') &&
1113
+ typeof item.$gt === 'string'
1114
+ ) {
1115
+ return {
1116
+ $gt: Sequelize.literal(item.$gt),
1117
+ }
1118
+ }
1102
1119
  return item
1103
1120
  } else {
1104
1121
  return item
@@ -53,9 +53,6 @@ exports.login = async (ctx) => {
53
53
  }
54
54
 
55
55
  if (!checkLoginResult) throw new Error('账号密码错误')
56
- const token = await app.sign({
57
- user: checkLoginResult,
58
- })
59
56
 
60
57
  const result = await app.model.administrator.findOne({
61
58
  where: {
@@ -74,6 +71,13 @@ exports.login = async (ctx) => {
74
71
  ],
75
72
  })
76
73
  const objResult = result.toJSON()
74
+ if (!objResult.role || !objResult.role.permission_id) {
75
+ throw new Error('无法登录,请重试')
76
+ }
77
+
78
+ const token = await app.sign({
79
+ user: checkLoginResult,
80
+ })
77
81
  return ctx.SUCCESS({
78
82
  token,
79
83
  user: {
@@ -74,6 +74,13 @@ exports.loadModel = async ({ app, appName }) => {
74
74
  }
75
75
  if (countNumber >= 500) {
76
76
  disabledFindAllList = [...disabledFindAllList, result[i]]
77
+ const tableIndexList = await app.service.system.getTableIndex({
78
+ app,
79
+ model: result[i],
80
+ })
81
+ if (tableIndexList.length <= 1) {
82
+ console.warn(`${result[i]} count ${countNumber}没有索引`)
83
+ }
77
84
  }
78
85
  }
79
86
 
@@ -581,7 +581,6 @@ exports.showAllModel = async (ctx) => {
581
581
  count,
582
582
  name: target.name,
583
583
  model: list[i],
584
- count,
585
584
  },
586
585
  ]
587
586
  }
@@ -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
- ...data,
255
+ ...formatData,
206
256
  }).then((result) => {
207
257
  const list =
208
258
  data && data.omit && Array.isArray(data.omit)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "11.8.5",
3
+ "version": "11.8.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {