Commit 26c62b91106ef8f879d365267b0677c48b97e153
1 parent
53d41089
多字段排序无效修改
将现有排序规则 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1,column2 desc" 修改为 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1 desc,column2 desc"
Showing
1 changed file
with
11 additions
and
2 deletions
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 { |
230 | 230 | //SQL注入check |
231 | 231 | SqlInjectionUtil.filterContent(column); |
232 | 232 | |
233 | + // 排序规则修改 | |
234 | + // 将现有排序 | |
235 | + // 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1,column2 desc" | |
236 | + // 修改为 | |
237 | + // 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1 desc,column2 desc" | |
233 | 238 | if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) { |
234 | - queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column)); | |
239 | + String columnStr = oConvertUtils.camelToUnderline(column); | |
240 | + String[] columnArray = columnStr.split(","); | |
241 | + queryWrapper.orderByAsc(columnArray); | |
235 | 242 | } else { |
236 | - queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column)); | |
243 | + String columnStr = oConvertUtils.camelToUnderline(column); | |
244 | + String[] columnArray = columnStr.split(","); | |
245 | + queryWrapper.orderByDesc(columnArray); | |
237 | 246 | } |
238 | 247 | } |
239 | 248 | } |
... | ... |