From 7389bfdee40eabf6d8c39252b5485184fc27c168 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Sat, 23 Jun 2018 11:01:29 +0800
Subject: [PATCH] 提交 为发现class

---
 src/main/java/com/moral/common/util/ExampleUtil.java |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/moral/common/util/ExampleUtil.java b/src/main/java/com/moral/common/util/ExampleUtil.java
index 3277d11..1852f44 100644
--- a/src/main/java/com/moral/common/util/ExampleUtil.java
+++ b/src/main/java/com/moral/common/util/ExampleUtil.java
@@ -19,17 +19,22 @@
     private final static String CRITERIA_SPLIT = "\\|\\|\\|";
     private final static String CONDITION_SPLIT = "\\|\\|";
     private static Map<String, Method> criteriaMethodMap = null;
-    private static void setOrderByClause(Example example,String orderByClause) throws UnsupportedEncodingException {
+    private static void setOrderByClause(Example example,String orderByClause) throws UnsupportedEncodingException, NoSuchFieldException {
            orderByClause = URLDecoder.decode(orderByClause,"UTF-8");
            String[] orderBys = orderByClause.split(CRITERIA_SPLIT);
            for(String orderBy : orderBys){
                String[] items = orderBy.split(CONDITION_SPLIT);
-               String property = items[0];
-               String sort = items[1];
-               if("asc".equals(sort)){
-                   example.orderBy(property).asc();
-               }else{
-                   example.orderBy(property).desc();
+               if(items.length == 2){
+                   String property = items[0];
+                   String sort = items[1];
+                   if(isPropertyOfClass(example.getEntityClass(),property)){
+
+                       if("asc".equals(sort)){
+                           example.orderBy(property).asc();
+                       }else{
+                           example.orderBy(property).desc();
+                       }
+                   }
                }
            }
     }
@@ -47,6 +52,8 @@
             if (!StringUtils.isNullOrEmpty(params) && params.startsWith("or|")) {
                 String[] criteria = params.trim().split(OR_SPLIT);
                 for (String criterion : criteria) {
+                    // criterion���null���""������
+                    if(StringUtils.isNullOrEmpty(criterion)) { continue;};
                     Example.Criteria criteriaOfExample = example.or();
                     if (!StringUtils.isNullOrEmpty(criterion)) {
                         String[] conditions = criterion.trim().split(CRITERIA_SPLIT);

--
Gitblit v1.8.0