春季数据休息,querydsl大于或小于搜索

时间:2018-07-20 16:25:18

标签: java querydsl

我正在尝试搜索查询参数orderedQty的值。如果有两个ord​​eredQty参数,我想检查该值,并根据该值执行大于或小于搜索,否则,我想执行并等于搜索。我现在拥有的是下面的代码,但是没有返回准确或一致的结果。

  MultiValueBinding<NumberPath<Integer>, Integer> numberPathContainsRange = (path, value) -> {
                Iterator<? extends Integer> it = value.iterator();
                Integer search = it.next();
                if (it.hasNext()) {
                    Integer range = it.next();
                    if (range == 1) {
                        System.out.println("Greater than: " + search);
                        // return results greater than or equals
                        return path.goe(search);
                    } else {
                        // return results less than or equals
                        System.out.println("Less than: " + search);
                        return path.loe(search);
                    }
                } else {
                    return path.eq(search);
                }
            };


bindings.bind(report.orderedQty).all(numberPathContainsRange);

0 个答案:

没有答案