q-koa 9.0.0 → 9.0.2

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.
@@ -96,8 +96,15 @@ exports.initRoute = async (ctx) => {
96
96
  },
97
97
  ]
98
98
 
99
- const permissionList = await app.model.permission.findAll()
100
- const modelList = await app.model.model.findAll()
99
+ const permissionList = await app.model.permission.findAll({
100
+ attributes: ['id', 'name', 'controller'],
101
+ raw: true,
102
+ })
103
+ const modelList = await app.model.model.findAll({
104
+ attributes: ['id', 'belongs', 'model'],
105
+ raw: true,
106
+ })
107
+
101
108
  const roleList = await app.model.role.findAll()
102
109
  const rolePermission = lodash.uniq(
103
110
  roleList
@@ -105,7 +112,7 @@ exports.initRoute = async (ctx) => {
105
112
  .reduce((a, b) => [...a, ...b.permission_id], [])
106
113
  )
107
114
  for (let i = 0; i < permissionList.length; i++) {
108
- const target = permissionList[i].toJSON()
115
+ const target = permissionList[i]
109
116
  if (target.controller === '') {
110
117
  await app.model.permission.destroy({
111
118
  where: {
@@ -128,18 +135,20 @@ exports.initRoute = async (ctx) => {
128
135
  const is_project = !model
129
136
  list = [
130
137
  ...list,
131
- {
132
- name: target.name,
133
- parent_id,
134
- url: is_project ? `/project/${appName}/` + target.controller : '',
135
- model_id: model ? model.id : 0,
136
- key: is_project
137
- ? ''
138
- : model && model.belongs
139
- ? `${model.belongs}/${model.model}`
140
- : '',
141
- },
142
- ]
138
+ model
139
+ ? {
140
+ name: target.name,
141
+ parent_id,
142
+ url: is_project ? `/project/` + target.controller : '',
143
+ model_id: model ? model.id : 0,
144
+ key: is_project
145
+ ? ''
146
+ : model && model.belongs
147
+ ? `${model.belongs}/${model.model}`
148
+ : '',
149
+ }
150
+ : null,
151
+ ].filter(Boolean)
143
152
  }
144
153
  const sortList = list.map((item) => {
145
154
  const sort = routesList.find((r) => r.name === item.name)
@@ -69,7 +69,7 @@ module.exports = class Singleton {
69
69
  const Print = new yly.Print(RpcClient)
70
70
  const res = await Print.index(this.config.machine_code, order_id, content)
71
71
 
72
- if (res.code !== '0') {
72
+ if (res && res.error_description !== 'success') {
73
73
  throw new Error(res.error_description)
74
74
  }
75
75
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {