@opengis/fastify-table 1.0.39 → 1.0.40
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/Changelog.md +4 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/widget/controllers/widget.get.js +22 -12
package/Changelog.md
CHANGED
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ async function plugin(fastify, opt) {
|
|
|
27
27
|
fastify.decorate('getFolder', (req, type = 'server') => {
|
|
28
28
|
if (!['server', 'local'].includes(type)) throw new Error('params type is invalid');
|
|
29
29
|
const types = { local: req.root, server: req.mapServerRoot };
|
|
30
|
-
const filepath = path.posix.join(types[type] || '/data/local', req.folder || '');
|
|
30
|
+
const filepath = path.posix.join(types[type] || '/data/local', req.folder || config.folder || '');
|
|
31
31
|
return filepath;
|
|
32
32
|
});
|
|
33
33
|
|
package/package.json
CHANGED
|
@@ -23,25 +23,35 @@ export default async function widgetGet({
|
|
|
23
23
|
if (!objectid) return { error: 'id required', status: 400 };
|
|
24
24
|
|
|
25
25
|
const sqls = {
|
|
26
|
-
comment:
|
|
26
|
+
comment: pg.pk['admin.users']
|
|
27
|
+
? `select communication_id, entity_id, body, subject, c.cdate, c.uid,
|
|
27
28
|
coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, avatar
|
|
28
|
-
from crm.communications c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc
|
|
29
|
+
from crm.communications c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc`
|
|
30
|
+
: 'select communication_id, entity_id, body, subject, cdate, uid from crm.communications where entity_id=$1 order by cdate desc',
|
|
29
31
|
|
|
30
32
|
history: `SELECT table_change_id, entity_id, entity_type, change_key, change_date, json_old, json_new, date_old,
|
|
31
33
|
date_new, number_old, number_new, bool_old, bool_new, text_old,
|
|
32
34
|
text_new, uid, cdate FROM log.table_changes where entity_id=$1 order by cdate desc, change_key limit 100`,
|
|
33
35
|
|
|
34
|
-
checklist:
|
|
35
|
-
|
|
36
|
+
checklist: pg.pk['admin.users']
|
|
37
|
+
? `SELECT checklist_id, entity_id, subject, is_done, done_date, c.uid, c.cdate, coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username,
|
|
38
|
+
avatar FROM crm.checklists c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc`
|
|
39
|
+
: 'SELECT checklist_id, entity_id, subject, is_done, done_date, uid, cdate FROM crm.checklists where entity_id=$1 order by cdate desc',
|
|
36
40
|
|
|
37
|
-
file:
|
|
41
|
+
file: pg.pk['admin.users']
|
|
42
|
+
? `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, c.ismain,
|
|
38
43
|
coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, isverified,
|
|
39
44
|
avatar, c.uid as author, file_status FROM crm.files c left join admin.users u on u.uid=c.uid
|
|
40
|
-
where entity_id=$1 and file_status<>3 order by cdate desc
|
|
41
|
-
|
|
45
|
+
where entity_id=$1 and file_status<>3 order by cdate desc`
|
|
46
|
+
: `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, uid, cdate, file_type, ismain,
|
|
47
|
+
isverified, uid as author, file_status FROM crm.files c where entity_id=$1 and file_status<>3 order by cdate desc`,
|
|
48
|
+
gallery: pg.pk['admin.users']
|
|
49
|
+
? `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, c.ismain,
|
|
42
50
|
coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, isverified,
|
|
43
51
|
avatar, c.uid as author, file_status FROM crm.files c left join admin.users u on u.uid=c.uid
|
|
44
|
-
where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc
|
|
52
|
+
where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc`
|
|
53
|
+
: `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, ismain,
|
|
54
|
+
isverified, uid as author, file_status FROM crm.files c where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc`,
|
|
45
55
|
|
|
46
56
|
};
|
|
47
57
|
const sql = sqls[params.type];
|
|
@@ -56,12 +66,12 @@ export default async function widgetGet({
|
|
|
56
66
|
time.push(Date.now());
|
|
57
67
|
|
|
58
68
|
/* Object info */
|
|
59
|
-
const { tableName } = await pg.one('select entity_type as "tableName" from log.table_changes where entity_id=$1 limit 1', [objectid]);
|
|
69
|
+
const { tableName } = pg.pk['log.table_changes'] ? await pg.one('select entity_type as "tableName" from log.table_changes where entity_id=$1 limit 1', [objectid]) : {};
|
|
60
70
|
const { pk } = await getMeta({ table: tableName });
|
|
61
71
|
|
|
62
|
-
const q = `select coalesce(b.user_name,'')||coalesce(' '||b.sur_name,'') as author, a.cdate, a.editor_date from ${tableName} a
|
|
63
|
-
left join admin.users b on a.uid=b.uid where a.${pk}=$1 limit 1
|
|
64
|
-
const data = pk ? await pg.one(q, [objectid]) : {};
|
|
72
|
+
const q = tableName && pg.pk['admin.users'] ? `select coalesce(b.user_name,'')||coalesce(' '||b.sur_name,'') as author, a.cdate, a.editor_date from ${tableName} a
|
|
73
|
+
left join admin.users b on a.uid=b.uid where a.${pk}=$1 limit 1` : undefined;
|
|
74
|
+
const data = pk && q ? await pg.one(q, [objectid]) : {};
|
|
65
75
|
|
|
66
76
|
if (query.debug && user?.user_type === 'admin') {
|
|
67
77
|
return {
|