@domain.js/main 0.4.19 → 0.4.20
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/dist/deps/rest/utils.js +18 -9
- package/package.json +1 -1
package/dist/deps/rest/utils.js
CHANGED
|
@@ -298,7 +298,7 @@ function Utils(cnf, deps) {
|
|
|
298
298
|
}
|
|
299
299
|
// 处理like
|
|
300
300
|
if (_.isString(params[`${name}_like`])) {
|
|
301
|
-
value = params[`${name}_like`].trim().replace(/\*/g, "%");
|
|
301
|
+
value = params[`${name}_like`].trim().replace(/\*/g, "%").replace(/_/g, "\\_");
|
|
302
302
|
if (!where[col])
|
|
303
303
|
where[col] = {};
|
|
304
304
|
where[col][sequelize_1.Op.like] = value;
|
|
@@ -309,13 +309,13 @@ function Utils(cnf, deps) {
|
|
|
309
309
|
if (!where[col])
|
|
310
310
|
where[col] = {};
|
|
311
311
|
where[col][sequelize_1.Op.or] = likes.map((x) => {
|
|
312
|
-
value = x.trim().replace(/\*/g, "%");
|
|
312
|
+
value = x.trim().replace(/\*/g, "%").replace(/_/g, "\\_");
|
|
313
313
|
return { [sequelize_1.Op.like]: value };
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
// 处理notLike
|
|
317
317
|
if (_.isString(params[`${name}_notLike`])) {
|
|
318
|
-
value = params[`${name}_notLike`].trim().replace(/\*/g, "%");
|
|
318
|
+
value = params[`${name}_notLike`].trim().replace(/\*/g, "%").replace(/_/g, "\\_");
|
|
319
319
|
if (!where[col])
|
|
320
320
|
where[col] = {};
|
|
321
321
|
where[col][sequelize_1.Op.notLike] = value;
|
|
@@ -369,8 +369,11 @@ function Utils(cnf, deps) {
|
|
|
369
369
|
_.each(Model.filterAttrs || _.keys(Model.rawAttributes), (name) => {
|
|
370
370
|
findOptFilter(params, name, where);
|
|
371
371
|
});
|
|
372
|
-
if (
|
|
373
|
-
|
|
372
|
+
if (!params._showDeleted) {
|
|
373
|
+
if (Model.rawAttributes.isDeleted)
|
|
374
|
+
where.isDeleted = "no";
|
|
375
|
+
if (Model.rawAttributes.deletedAt)
|
|
376
|
+
where.deletedAt = null;
|
|
374
377
|
}
|
|
375
378
|
// 将搜索条件添加到主条件上
|
|
376
379
|
const searchOptRes = searchOpt(Model, params._searchs, params.q);
|
|
@@ -385,10 +388,16 @@ function Utils(cnf, deps) {
|
|
|
385
388
|
_.each(filterAttrs, (name) => {
|
|
386
389
|
findOptFilter(params, `${x.as}.${name}`, includeWhere, name);
|
|
387
390
|
});
|
|
388
|
-
if (
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
391
|
+
if (!params._showDeleted) {
|
|
392
|
+
if (x.model.rawAttributes.isDeleted || x.model.rawAttributes.deletedAt) {
|
|
393
|
+
includeWhere[sequelize_1.Op.or] = [];
|
|
394
|
+
if (x.model.rawAttributes.isDeleted)
|
|
395
|
+
includeWhere[sequelize_1.Op.or].push({ isDeleted: "no" });
|
|
396
|
+
if (x.model.rawAttributes.deletedAt)
|
|
397
|
+
includeWhere[sequelize_1.Op.or].push({ deletedAt: null });
|
|
398
|
+
if (x.required === false)
|
|
399
|
+
includeWhere[sequelize_1.Op.or].push({ id: null });
|
|
400
|
+
}
|
|
392
401
|
}
|
|
393
402
|
// 将搜索条件添加到 include 的 where 条件上
|
|
394
403
|
const searchOptResII = searchOpt(x.model, params._searchs, params.q, x.as);
|