Commit e75828d3 by chenjinjing

no message

parent f824e322
......@@ -17,14 +17,15 @@ import { BizError } from "../util/bizError";
* %notBetween%:查询不在范围内数据 {列名: {"%notBetween%": ["开始参数", "结束参数"]}} ---NOT BETWEEN 开始参数 AND 结束参数
* %orderDesc%: order by DESC {"%orderDesc%": "列名"}
* %limit%: {"%limit%": 数量}
* %literal%: 拼接查询sql条件 {"%literal%": `sql语句`} 例如:start BETWEEN 1 and 3
* @param column
* @returns
*/
function analysisParamToWhere(param, column) {
let where = {};
let or = {};
let order = [];
let group = "";
let literal = "";
let limit = 0;
for (let key in param) {
if (key == "%or%") {
......@@ -63,6 +64,9 @@ function analysisParamToWhere(param, column) {
case "%ne%"://不等于
where[key][Op.ne] = param[key]["%ne%"];
break;
case "%regexp%":
where[key][Op.regexp] = param[key]["%regexp%"];
break;
}
}
} else {
......@@ -79,6 +83,9 @@ function analysisParamToWhere(param, column) {
case "%group%":
group = param[key];
break;
case "%literal%":
literal = param["%literal%"];
break;
default: where[key] = param[key];
}
}
......@@ -89,6 +96,7 @@ function analysisParamToWhere(param, column) {
if (order && order.length) selectParam.order = order;
if (limit) selectParam.limit = limit;
if (group) selectParam.group = group;
if (literal) selectParam.where = Sequelize.literal(literal);
return selectParam;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment