q-koa 11.8.3 → 11.8.6

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,24 @@ class APP {
1099
1099
  $in: [Sequelize.literal(item.$in)],
1100
1100
  }
1101
1101
  }
1102
+ console.log(item.$lt)
1103
+ if (
1104
+ item.hasOwnProperty('$lt') &&
1105
+ typeof item.$lt === 'string'
1106
+ ) {
1107
+ return {
1108
+ $lt: Sequelize.literal(item.$lt),
1109
+ }
1110
+ }
1111
+
1112
+ if (
1113
+ item.hasOwnProperty('$gt') &&
1114
+ typeof item.$gt === 'string'
1115
+ ) {
1116
+ return {
1117
+ $gt: Sequelize.literal(item.$gt),
1118
+ }
1119
+ }
1102
1120
  return item
1103
1121
  } else {
1104
1122
  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: {
@@ -3,13 +3,21 @@ module.exports = {
3
3
  belongs: 'page',
4
4
  multiple: false,
5
5
  availableSort: false,
6
- order: ["created_at"],
7
- select: [{"key":"user_id"},{"key":"nick_name"}],
6
+ order: ['created_at'],
7
+ select: [{ key: 'user_id' }, { key: 'nick_name' }],
8
8
  excludes: [],
9
9
  limit: 20,
10
10
  defaultOrder: [{ sort: 'descending', type: 'id' }],
11
- comment: {"created_at":"创建时间"},
11
+ comment: { created_at: '创建时间' },
12
12
  sortOrder: 1,
13
13
  reference: [],
14
14
  excludeAuth: [],
15
+ indexList: [
16
+ {
17
+ name: 'openid',
18
+ unique: true,
19
+ fields: ['openid'],
20
+ },
21
+ { fields: ['user_id'] },
22
+ ],
15
23
  }
@@ -16,4 +16,12 @@ module.exports = {
16
16
  sortOrder: 1,
17
17
  reference: [],
18
18
  excludeAuth: [],
19
+ indexList: [
20
+ {
21
+ name: 'openid',
22
+ unique: true,
23
+ fields: ['openid'],
24
+ },
25
+ { fields: ['user_id'] },
26
+ ],
19
27
  }
@@ -7,7 +7,7 @@ exports.openid = {
7
7
  is_mock: false,
8
8
  defaultValue: '',
9
9
  sortOrder: 1,
10
- unique: true,
10
+ unique: ['openid'],
11
11
  }
12
12
 
13
13
  exports.user_id = {
@@ -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
  }
@@ -731,7 +730,7 @@ exports.checkIndex = async (ctx) => {
731
730
  ...res,
732
731
  [current]: {
733
732
  isSame,
734
- tableIndexList,
733
+ indexList: tableIndexList.filter((i) => i.name !== 'PRIMARY'),
735
734
  },
736
735
  }
737
736
  }
@@ -751,7 +750,9 @@ exports.checkIndex = async (ctx) => {
751
750
  const isSame = compareIndex(tableIndexList, modelIndexList, model)
752
751
  return ctx.SUCCESS({
753
752
  isSame,
754
- ...(isSame ? {} : { tableIndexList }),
753
+ ...(isSame
754
+ ? {}
755
+ : { indexList: tableIndexList.filter((i) => i.name !== 'PRIMARY') }),
755
756
  })
756
757
  }
757
758
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "11.8.3",
3
+ "version": "11.8.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {