@domain.js/main 0.4.19 → 0.4.21

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.
@@ -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,9 @@ function Utils(cnf, deps) {
369
369
  _.each(Model.filterAttrs || _.keys(Model.rawAttributes), (name) => {
370
370
  findOptFilter(params, name, where);
371
371
  });
372
- if (Model.rawAttributes.isDeleted && !params._showDeleted) {
373
- where.isDeleted = "no";
372
+ if (!params._showDeleted) {
373
+ if (Model.rawAttributes.isDeleted)
374
+ where.isDeleted = "no";
374
375
  }
375
376
  // 将搜索条件添加到主条件上
376
377
  const searchOptRes = searchOpt(Model, params._searchs, params.q);
@@ -385,10 +386,16 @@ function Utils(cnf, deps) {
385
386
  _.each(filterAttrs, (name) => {
386
387
  findOptFilter(params, `${x.as}.${name}`, includeWhere, name);
387
388
  });
388
- if (x.model.rawAttributes.isDeleted && !params._showDeleted) {
389
- includeWhere[sequelize_1.Op.or] = [{ isDeleted: "no" }];
390
- if (x.required === false)
391
- includeWhere[sequelize_1.Op.or].push({ id: null });
389
+ if (!params._showDeleted) {
390
+ if (x.model.rawAttributes.isDeleted || x.model.rawAttributes.deletedAt) {
391
+ includeWhere[sequelize_1.Op.or] = [];
392
+ if (x.model.rawAttributes.isDeleted)
393
+ includeWhere[sequelize_1.Op.or].push({ isDeleted: "no" });
394
+ if (x.model.rawAttributes.deletedAt)
395
+ includeWhere[sequelize_1.Op.or].push({ deletedAt: null });
396
+ if (x.required === false)
397
+ includeWhere[sequelize_1.Op.or].push({ id: null });
398
+ }
392
399
  }
393
400
  // 将搜索条件添加到 include 的 where 条件上
394
401
  const searchOptResII = searchOpt(x.model, params._searchs, params.q, x.as);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.4.19",
3
+ "version": "0.4.21",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {