@domain.js/main 0.4.12 → 0.4.14

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.
@@ -69,18 +69,20 @@ function Utils(cnf, deps) {
69
69
  if (!value)
70
70
  return [[conf.default, conf.defaultDirection || "ASC"]];
71
71
  const orders = value.split(",").map((x) => {
72
+ var _a;
72
73
  const isDesc = x[0] === "-";
73
74
  const direction = isDesc ? "DESC" : "ASC";
74
75
  const order = isDesc ? x.slice(1) : x;
76
+ const theOrder = order.split(".");
75
77
  // 如果请求的排序方式不允许,则返回null
76
- if (!conf.allow || !_.includes(conf.allow, order))
78
+ if (theOrder.length !== 2 && (!conf.allow || !_.includes(conf.allow, order)))
77
79
  return undefined;
78
- const theOrder = order.split(".");
79
80
  // 处理使用模型名称作为关联名称按关联模型的 字段 排序
80
81
  if (theOrder.length === 2) {
81
82
  if (includes && Array.isArray(params._includes)) {
82
83
  const ret = _.filter(params._includes, (val) => includes[val]);
83
- if (!ret.includes(theOrder[0])) {
84
+ if (!ret.includes(theOrder[0]) ||
85
+ !((_a = includes[theOrder[0]].model.sort) === null || _a === void 0 ? void 0 : _a.allow.includes(theOrder[1]))) {
84
86
  return undefined;
85
87
  }
86
88
  }
@@ -361,6 +363,7 @@ function Utils(cnf, deps) {
361
363
  // 返回列表查询的条件
362
364
  const findAllOpts = (Model, params) => {
363
365
  const { Op } = Sequelize;
366
+ const { literal } = Model.sequelize;
364
367
  const where = {};
365
368
  const searchOrs = [];
366
369
  const includes = modelInclude(params, Model.includes);
@@ -408,14 +411,14 @@ function Utils(cnf, deps) {
408
411
  const _searchOrs = _.filter(_.compact(searchOrs), (x) => x.length);
409
412
  if (_.size(where)) {
410
413
  if (_searchOrs.length) {
411
- ret.where = Sequelize.and(where, Sequelize.literal(mergeSearchOrs(_searchOrs)));
414
+ ret.where = Sequelize.and(where, literal(mergeSearchOrs(_searchOrs)));
412
415
  }
413
416
  else {
414
417
  ret.where = where;
415
418
  }
416
419
  }
417
420
  else if (_searchOrs.length) {
418
- ret.where = Sequelize.literal(mergeSearchOrs(_searchOrs));
421
+ ret.where = literal(mergeSearchOrs(_searchOrs));
419
422
  }
420
423
  // 处理需要返回的字段
421
424
  (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {