q-koa 8.9.4 → 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
|
-
|
|
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]
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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.
|
|
72
|
+
if (res && res.error_description !== 'success') {
|
|
73
73
|
throw new Error(res.error_description)
|
|
74
74
|
}
|
|
75
75
|
} catch (e) {
|
|
@@ -100,7 +100,14 @@ module.exports = class Singleton {
|
|
|
100
100
|
return cache.get(appid)
|
|
101
101
|
}
|
|
102
102
|
const url = util.format(getAccessTokenUrl, grant_type, appid, secrect)
|
|
103
|
-
|
|
103
|
+
|
|
104
|
+
const result = await axios.get(url).then((res) => res.data)
|
|
105
|
+
const { errcode, errmsg, access_token } = result
|
|
106
|
+
|
|
107
|
+
if (errcode) {
|
|
108
|
+
throw new Error(errmsg)
|
|
109
|
+
}
|
|
110
|
+
|
|
104
111
|
cache.set(appid, access_token)
|
|
105
112
|
return access_token
|
|
106
113
|
}
|