Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eq的条件比较的范围,加个直接接受数组的方法 #237

Closed
wm26hua opened this issue Jun 17, 2024 · 1 comment
Closed

eq的条件比较的范围,加个直接接受数组的方法 #237

wm26hua opened this issue Jun 17, 2024 · 1 comment

Comments

@wm26hua
Copy link

wm26hua commented Jun 17, 2024

因为前端时间范围组件,一般给的数据结构是个数组,["2024-06-01 00:00:00","2024-07-31 00:00:00"]

@xuejmnet
Copy link
Collaborator

我想了半天发现这个api可能并没有我一开始想的那么简单,首先如果你传入的是null怎么办,默认框架是不会进行过滤的这个时候range函数的处理和空数组处理还有数组内就一个元素的时候处理如果全部改成自适应那么相当于是违反了之前的方式,如果传入空或者null或者一个数组那么range前后又都是null就会和这个api相悖,所以我再三思考还是不打算增加这个api,您可以编写一个util

    public static <TValue> TValue getIndexValueOrNull(TValue[] values,int index){
        if(index<0){
            throw new IllegalArgumentException("index < 0.");
        }
        if(EasyArrayUtil.isEmpty(values)){
            return null;
        }
        if(values.length<=index){
            return null;
        }
        return values[index];
    }



        LocalDateTime[]  times= new LocalDateTime[2];
        List<Topic> list1 = easyEntityQuery.queryable(Topic.class)
                .where(t -> {
                    t.createTime().rangeClosed(getIndexValueOrNull(times, 0), getIndexValueOrNull(times, 1));
                }).toList();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants