fengxiang
2018-06-14 01d77db2f4d991afcd2a9a34213e12a4cdc87d67
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);