|
@@ -1,6 +1,6 @@
|
|
|
import { App, Inject, MidwayWebRouterService } from '@midwayjs/core';
|
|
|
import { Application, Context } from '@midwayjs/koa';
|
|
|
-import { compact, flattenDeep, get, head, isArray, isNull, isNumber, isObject, isString, isUndefined, last, uniq } from 'lodash';
|
|
|
+import { compact, flattenDeep, get, head, isArray, isNull, isObject, isFinite, isString, isUndefined, last, uniq } from 'lodash';
|
|
|
import { Opera } from './dbOpera';
|
|
|
import { Opera as operaModel } from '../entityLogs/opera.entity';
|
|
|
import dayjs = require('dayjs');
|
|
@@ -69,12 +69,12 @@ export abstract class BaseServiceV2 {
|
|
|
// 分页
|
|
|
if (isString(skip)) {
|
|
|
skip = parseInt(skip);
|
|
|
- if (isNumber(skip)) builder.skip(skip);
|
|
|
- } else if (isNumber(skip)) builder.skip(skip);
|
|
|
+ if (isFinite(skip)) builder.skip(skip);
|
|
|
+ } else if (isFinite(skip)) builder.skip(skip);
|
|
|
if (isString(limit)) {
|
|
|
limit = parseInt(limit);
|
|
|
- if (isNumber(limit)) builder.take(limit);
|
|
|
- } else if (isNumber(limit)) builder.take(limit);
|
|
|
+ if (isFinite(limit)) builder.take(limit);
|
|
|
+ } else if (isFinite(limit)) builder.take(limit);
|
|
|
// 排序
|
|
|
builder.orderBy(orderObject);
|
|
|
// 执行
|
|
@@ -187,6 +187,40 @@ export abstract class BaseServiceV2 {
|
|
|
}
|
|
|
str = `(${strArr.join(' OR ')})`;
|
|
|
break;
|
|
|
+ case this.Opera.JsonObject:
|
|
|
+ const jokeys = key.split('.');
|
|
|
+ let jorootCol = head(jokeys);
|
|
|
+ let jolastKey = last(jokeys);
|
|
|
+ let jopath = jokeys.filter(f => f !== jorootCol && f !== jolastKey);
|
|
|
+ str = `"${jorootCol}" `
|
|
|
+ for (const jok of jopath) {
|
|
|
+ str = `${str} -> ${jok}`
|
|
|
+ }
|
|
|
+ str = `${str} ->> '${jolastKey}' = :${valueStr}`
|
|
|
+ params = { [`${valueStr}`]: value };
|
|
|
+ break;
|
|
|
+ case this.Opera.JsonArrayObject:
|
|
|
+ /**
|
|
|
+ * 1.分割key,过来的属性默认以 x.y.z... 形式
|
|
|
+ * x:根子段;后面,数组中依次往下的属性名
|
|
|
+ */
|
|
|
+ const keys = key.split('.');
|
|
|
+ let newValue = value;
|
|
|
+ if (isFinite(parseInt(newValue))) newValue = parseInt(value);
|
|
|
+ let rootCol = head(keys);
|
|
|
+ let lastKey = last(keys);
|
|
|
+ let path = keys.filter(f => f !== rootCol && f !== lastKey);
|
|
|
+ let obj = {};
|
|
|
+ let mid = obj;
|
|
|
+ for (const k of path) {
|
|
|
+ mid[k] = {};
|
|
|
+ mid = mid[k];
|
|
|
+ }
|
|
|
+ mid[lastKey] = newValue;
|
|
|
+ let newVal = JSON.stringify([obj]);
|
|
|
+ str = `"${rootCol}" @> :${valueStr}`;
|
|
|
+ params = { [`${valueStr}`]: newVal };
|
|
|
+ break;
|
|
|
case this.Opera.Equal:
|
|
|
default:
|
|
|
str = `"${key}" = :${valueStr}`;
|