JAVA:

    public Map getPage(final Map searchParameters, String salt) {
            Map map = new HashMap();
            int page = 0;
            int pageSize = 10;
            Page pageList;
            if (searchParameters != null && searchParameters.size() > 0 && searchParameters.get("page") != null) {
                page = Integer.parseInt(searchParameters.get("page").toString()) - 1;
            }
            if (searchParameters != null && searchParameters.size() > 0 && searchParameters.get("pageSize") != null) {
                pageSize = Integer.parseInt(searchParameters.get("pageSize").toString());
            }
            if (pageSize < 1)
                pageSize = 1;
            if (pageSize > 100)
                pageSize = 100;
            List orderMaps = (List) searchParameters.get("sort");
            List orders = new ArrayList();
            if (orderMaps != null) {
                for (Map m : orderMaps) {
                    if (m.get("field") == null)
                        continue;
                    String field = m.get("field").toString();
                    if (!StringUtils.isEmpty(field)) {
                        String dir = m.get("dir").toString();
                        if ("DESC".equalsIgnoreCase(dir)) {
                            orders.add(new Order(Direction.DESC, field));
                        } else {
                            orders.add(new Order(Direction.ASC, field));
                        }
                    }
                }
            }
            PageRequest pageable;
            if (orders.size() > 0) {
                pageable = new PageRequest(page, pageSize, new Sort(orders));
            } else {
                Sort s = new Sort(Direction.ASC, "userIndex");
                pageable = new PageRequest(page, pageSize, s);
            }
            Map filter = (Map) searchParameters.get("filter");
            if (filter != null) {
                final List filters = (List) filter.get("filters");
                Specification spec = new Specification() {
                    @Override
                    public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) {
                        List pl = new ArrayList();
                        for (Map f : filters) {
                            String field = f.get("field").toString().trim();
                            String value = f.get("value").toString().trim();
                            if (value != null && value.length() > 0) {
                                if ("loginName".equalsIgnoreCase(field)) {
                                    pl.add(cb.equal(root.get(field), value));
                                } else if ("userName".equalsIgnoreCase(field)) {
                                    pl.add(cb.like(root.get(field), value + "%"));
                                } else if ("email".equalsIgnoreCase(field)) {
                                    pl.add(cb.like(root.get(field), value + "%"));
                                } else if ("state".equalsIgnoreCase(field)) {
                                    pl.add(cb.equal(root.get("state"), value));
                                }
                            }
                        }
                        // 查询出未删除的
                        pl.add(cb.equal(root.get("flag"), 1));
                        // pl.add(cb.equal(root.get("state"), 1));
                        return cb.and(pl.toArray(new Predicate[0]));
                    }
                };
                pageList = userRepository.findAll(spec, pageable);

            } else {
                Specification spec = new Specification() {
                    public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) {
                        List list = new ArrayList();
                        // 查询出未删除的
                        list.add(cb.equal(root.get("flag"), 1));
                        list.add(cb.equal(root.get("state"), 1));
                        return cb.and(list.toArray(new Predicate[0]));
                    }
                };
                pageList = userRepository.findAll(spec, pageable);

            }

            map.put("total", pageList.getTotalElements());
            map.put("users", userList2DtoList(pageList.getContent(), salt));
            return map;
        }