@digione/node-custom-api 0.1.9-alpha11 → 0.1.9-alpha13
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/package.json +1 -1
- package/utils/db.js +5 -5
- package/utils/user.js +5 -3
package/package.json
CHANGED
package/utils/db.js
CHANGED
|
@@ -32,12 +32,12 @@ const getWhereVal = (smth) => {
|
|
|
32
32
|
return [key, value].join(` ${smth.comparator} `);
|
|
33
33
|
};
|
|
34
34
|
const genWhere = (where = {}, { as = "", delimiter = ".", prefix = true, bracket = false } = {}) => {
|
|
35
|
-
|
|
35
|
+
let keyPrefix = as ? "`" + as + "`" + delimiter : as;
|
|
36
36
|
let symbolKeys = Object.getOwnPropertySymbols(where);
|
|
37
37
|
let rawWhere = (Object.keys(where).concat(symbolKeys)).reduce((result, key) => {
|
|
38
38
|
let value = where[key];
|
|
39
39
|
if (typeof value !== 'undefined') {
|
|
40
|
-
key = typeof (
|
|
40
|
+
key = typeof (key) == "string" ? keyPrefix + "`" + key + "`" : key;
|
|
41
41
|
if (typeof (value) == "string") {
|
|
42
42
|
value = SqlString.escape(value);
|
|
43
43
|
}
|
|
@@ -48,7 +48,7 @@ const genWhere = (where = {}, { as = "", delimiter = ".", prefix = true, bracket
|
|
|
48
48
|
result = `${result}( ${op}) AND `;
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
|
-
result = result +
|
|
51
|
+
result = result + key + ` IN (${value.map(i => "'" + i + "'").join(',')}) AND `;
|
|
52
52
|
}
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
@@ -62,10 +62,10 @@ const genWhere = (where = {}, { as = "", delimiter = ".", prefix = true, bracket
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
else if (typeof value == "object" && value['val']) {
|
|
65
|
-
result = result +
|
|
65
|
+
result = result + key + `=${value['val']} AND `;
|
|
66
66
|
return result;
|
|
67
67
|
}
|
|
68
|
-
result = result +
|
|
68
|
+
result = result + key + "=" + value + " AND ";
|
|
69
69
|
}
|
|
70
70
|
return result;
|
|
71
71
|
}, "");
|
package/utils/user.js
CHANGED
|
@@ -317,9 +317,11 @@ const getGroupSetting = (ref, id, { attributes = ['id', 'shared', 'setting'] } =
|
|
|
317
317
|
exports.getGroupSetting = getGroupSetting;
|
|
318
318
|
const getGroupPermission = (ref, id, module, { permission = {}, group_shared = undefined, organ_id = 0, attributes = ['id', 'shared', 'setting'] } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
319
319
|
if (typeof group_shared == "undefined") {
|
|
320
|
-
let
|
|
321
|
-
if (
|
|
322
|
-
|
|
320
|
+
let group = yield (0, exports.getGroupSetting)(ref, id, { attributes });
|
|
321
|
+
if (group) {
|
|
322
|
+
permission['setting'] = group['setting'] || {};
|
|
323
|
+
group_shared = group['shared'];
|
|
324
|
+
}
|
|
323
325
|
}
|
|
324
326
|
if (typeof group_shared != "undefined" && group_shared == 0) {
|
|
325
327
|
let query = yield group_permission_1.UserGroupPermissionModel.schema(ref, "_").findOne({
|