zet-lib 1.2.88 → 1.2.90
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/lib/zAppRouter.js +0 -52
- package/lib/zCache.js +6 -44
- package/lib/zGeneratorRouter.js +1 -1
- package/package.json +1 -1
package/lib/zAppRouter.js
CHANGED
|
@@ -124,58 +124,6 @@ router.post('/profile-sign', access, async (req, res) => {
|
|
|
124
124
|
res.json(json)
|
|
125
125
|
})
|
|
126
126
|
|
|
127
|
-
router.get('/znotification/:token', async (req, res) => {
|
|
128
|
-
const MYMODELS = myCache.get('MYMODELS')
|
|
129
|
-
let MYMODEL = MYMODELS['zuser']
|
|
130
|
-
let token = req.params.token
|
|
131
|
-
let url = '/dashboard'
|
|
132
|
-
let results = await connection.results({ table: 'znotification', where: { token: token } })
|
|
133
|
-
if (results.length) {
|
|
134
|
-
let data = {
|
|
135
|
-
status: 2,
|
|
136
|
-
}
|
|
137
|
-
await connection.update({ table: 'znotification', data: data, where: { token: token } })
|
|
138
|
-
if (results[0].link) {
|
|
139
|
-
return res.redirect(results[0].link)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return res.redirect(url)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
router.post('/notification-data', csrfProtection, async (req, res) => {
|
|
146
|
-
let id = req.query.id
|
|
147
|
-
let rows = await connection.results({
|
|
148
|
-
table: 'znotification',
|
|
149
|
-
where: {
|
|
150
|
-
user_id: res.locals.userId,
|
|
151
|
-
//status: 1
|
|
152
|
-
},
|
|
153
|
-
limit: 10,
|
|
154
|
-
orderBy: ['id', 'desc'],
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
let rowsCount = await connection.result({
|
|
158
|
-
select: ' count(id) as count ',
|
|
159
|
-
table: 'znotification',
|
|
160
|
-
where: {
|
|
161
|
-
user_id: res.locals.userId,
|
|
162
|
-
},
|
|
163
|
-
})
|
|
164
|
-
let arr = []
|
|
165
|
-
rows.forEach(function (item) {
|
|
166
|
-
item.ago = moment(item.updated_at).fromNow()
|
|
167
|
-
item.avatar = res.locals.userAvatar
|
|
168
|
-
arr.push(item)
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
let data = {
|
|
172
|
-
count: rowsCount.count,
|
|
173
|
-
data: arr,
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
res.json(data)
|
|
177
|
-
})
|
|
178
|
-
|
|
179
127
|
//check status user login in session
|
|
180
128
|
router.put('/zuser-session', csrfProtection, async (req, res) => {
|
|
181
129
|
let json = Util.flashError('err')
|
package/lib/zCache.js
CHANGED
|
@@ -19,7 +19,7 @@ zCache.KEYS = {
|
|
|
19
19
|
ZFUNCTIONS: 'ZFUNCTIONS',
|
|
20
20
|
VERSIONS: 'VERSIONS',
|
|
21
21
|
MODELS_RELATIONS: 'MODELS_RELATIONS',
|
|
22
|
-
APPROVAL_LEVELS
|
|
22
|
+
APPROVAL_LEVELS: 'APPROVAL_LEVELS',
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
zCache.STATICS = zCache.KEYS
|
|
@@ -62,12 +62,6 @@ const cache = async () => {
|
|
|
62
62
|
} else {
|
|
63
63
|
await zCache.MYMODELS()
|
|
64
64
|
}
|
|
65
|
-
if (myCache.has('CONFIG')) {
|
|
66
|
-
i = i + 1
|
|
67
|
-
} else {
|
|
68
|
-
//console.log("cache CONFIG not exist " + i)
|
|
69
|
-
await zCache.CONFIG()
|
|
70
|
-
}
|
|
71
65
|
if (myCache.has('MENU')) {
|
|
72
66
|
i = i + 1
|
|
73
67
|
} else {
|
|
@@ -87,7 +81,7 @@ const cache = async () => {
|
|
|
87
81
|
await zCache.ZFUNCTIONS()
|
|
88
82
|
}
|
|
89
83
|
if (myCache.has('APPROVAL_LEVELS')) {
|
|
90
|
-
|
|
84
|
+
i = i + 1
|
|
91
85
|
} else {
|
|
92
86
|
await zCache.APPROVAL_LEVELS()
|
|
93
87
|
}
|
|
@@ -176,38 +170,6 @@ zCache.VERSIONS = () => {
|
|
|
176
170
|
}
|
|
177
171
|
}
|
|
178
172
|
|
|
179
|
-
zCache.CONFIG = async () => {
|
|
180
|
-
let results = async () => {
|
|
181
|
-
return await connection.results({
|
|
182
|
-
table: 'zconfig',
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
let companies = await connection.results({
|
|
186
|
-
table: 'zcompany',
|
|
187
|
-
})
|
|
188
|
-
let r = await results()
|
|
189
|
-
let configObj = Util.arrayToObject(r, 'company_id')
|
|
190
|
-
for (let i = 0; i < companies.length; i++) {
|
|
191
|
-
let item = companies[i]
|
|
192
|
-
if (!configObj[item.id]) {
|
|
193
|
-
await connection.insert({
|
|
194
|
-
table: 'zconfig',
|
|
195
|
-
data: {
|
|
196
|
-
company_id: item.id,
|
|
197
|
-
layout: 0,
|
|
198
|
-
json: JSON.stringify(CONFIG),
|
|
199
|
-
created_at: Util.now(),
|
|
200
|
-
updated_at: Util.now(),
|
|
201
|
-
},
|
|
202
|
-
})
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
myCache.set(zCache.KEYS.CONFIG, Util.arrayToObject(await results(), 'company_id'))
|
|
207
|
-
//add to version after set
|
|
208
|
-
zCache.updateVersions(zCache.KEYS.CONFIG)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
173
|
zCache.MENU = async () => {
|
|
212
174
|
let results = async () => {
|
|
213
175
|
return await connection.results({
|
|
@@ -322,15 +284,15 @@ zCache.MODELS_RELATIONS = async () => {
|
|
|
322
284
|
}
|
|
323
285
|
}
|
|
324
286
|
|
|
325
|
-
zCache.APPROVAL_LEVELS = async() => {
|
|
287
|
+
zCache.APPROVAL_LEVELS = async () => {
|
|
326
288
|
if (myCache.has('APPROVAL_LEVELS')) {
|
|
327
289
|
return myCache.get('APPROVAL_LEVELS')
|
|
328
290
|
} else {
|
|
329
291
|
let results = await connection.results({
|
|
330
|
-
select:'id,name,color',
|
|
331
|
-
table:'zapproval_type'
|
|
292
|
+
select: 'id,name,color',
|
|
293
|
+
table: 'zapproval_type',
|
|
332
294
|
})
|
|
333
|
-
let obj = Util.arrayToObject(results,
|
|
295
|
+
let obj = Util.arrayToObject(results, 'id')
|
|
334
296
|
myCache.set('APPROVAL_LEVELS', obj)
|
|
335
297
|
return obj
|
|
336
298
|
}
|
package/lib/zGeneratorRouter.js
CHANGED
|
@@ -16,7 +16,7 @@ const ejs = require('ejs')
|
|
|
16
16
|
var app = express()
|
|
17
17
|
const path = require('path')
|
|
18
18
|
|
|
19
|
-
const nots = ['index', 'uploads', 'js', 'css', 'log', 'generator', 'zmenu', 'zgenerator', 'zfields', 'zrole', 'zfunction', 'zgrid', 'zgrid_default', 'zreport', 'zpage', 'zlayout', 'zerror', 'zuser_company'
|
|
19
|
+
const nots = ['index', 'uploads', 'js', 'css', 'log', 'generator', 'zmenu', 'zgenerator', 'zfields', 'zrole', 'zfunction', 'zgrid', 'zgrid_default', 'zreport', 'zpage', 'zlayout', 'zerror', 'zuser_company']
|
|
20
20
|
//const nots = [];
|
|
21
21
|
//const generatorUrl = 'http://localhost:3005';
|
|
22
22
|
const generatorUrl = 'https://generator.cmsqu.com'
|