From 26c62b91106ef8f879d365267b0677c48b97e153 Mon Sep 17 00:00:00 2001 From: wanglei <alan3258@163.com> Date: Sun, 7 Feb 2021 18:16:00 +0800 Subject: [PATCH] 多字段排序无效修改 将现有排序规则 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1,column2 desc" 修改为 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1 desc,column2 desc" --- jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java index d5f9c73..a8e8137 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/query/QueryGenerator.java @@ -230,10 +230,19 @@ public class QueryGenerator { //SQL注入check SqlInjectionUtil.filterContent(column); + // 排序规则修改 + // 将现有排序 + // 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1,column2 desc" + // 修改为 + // 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1 desc,column2 desc" if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) { - queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column)); + String columnStr = oConvertUtils.camelToUnderline(column); + String[] columnArray = columnStr.split(","); + queryWrapper.orderByAsc(columnArray); } else { - queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column)); + String columnStr = oConvertUtils.camelToUnderline(column); + String[] columnArray = columnStr.split(","); + queryWrapper.orderByDesc(columnArray); } } } -- libgit2 0.22.2