| | |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | 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); |