com.yuehuanghun.mybatis.milu.criteria.LambdaQueryPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-milu Show documentation
Show all versions of mybatis-milu Show documentation
A mybatis orm enhance framework.
/*
* Copyright 2020-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yuehuanghun.mybatis.milu.criteria;
import java.util.function.Consumer;
import javax.persistence.LockModeType;
import javax.persistence.Version;
import com.yuehuanghun.mybatis.milu.annotation.JoinMode;
import com.yuehuanghun.mybatis.milu.annotation.Mode;
import com.yuehuanghun.mybatis.milu.criteria.lambda.SerializableFunction;
import com.yuehuanghun.mybatis.milu.data.Sort.Direction;
import com.yuehuanghun.mybatis.milu.pagehelper.Pageable;
import com.yuehuanghun.mybatis.milu.data.Sort;
/**
* 使用实体类的getter函数式作为查询条件,如实体类属性(的get方法)有变更能通过IDE直接感知
* 有局限性,目前不能使用关联表的属性作为查询条件
* 举例:
* 当使用实体类接收查询参数:Foo foo = ...; fooMapper.findByLambdaCriteria(predicate -> predicate.apply(foo).eq(Foo:getBar));
* 当使用非实体类接口查询数:FooDTO fooDto = ...; fooMapper.findByLambdaCriteria(predicate -> predicate.eq(Foo:getBar), fooDto.getBar());
* @author yuehuanghun
*
* @param 实体类
*/
public interface LambdaQueryPredicate extends LambdaPredicate {
/**
* 指定查询的(实体类)属性,未指定时查询实体所有属性
* @param getterFns 实体类的getter函数式
* @return 当前对象
*/
@SuppressWarnings("unchecked")
LambdaQueryPredicate select(SerializableFunction... getterFns);
/**
* 指定查询的(实体类)属性,未指定时查询实体所有属性
* @param attrNameChain 多个属性名用英文逗号隔开,举例:name, age, createTime
* @return 当前对象
*/
LambdaQueryPredicate selects(String attrNameChain);
/**
* 排除查询指定的(实体类)属性,select比exselect优先级更高
* 例如文本或二进制大字段,影响IO效率,在查询时排除掉
* @param getterFns 实体类的getter函数式
* @return 当前对象
*/
@SuppressWarnings("unchecked")
LambdaQueryPredicate exselect(SerializableFunction... getterFns);
/**
* 排除查询指定的(实体类)属性,select比exselect优先级更高
* 例如文本或二进制大字段,影响IO效率,在查询时排除掉
* @param attrNameChain 多个属性名用英文逗号隔开,举例:content, fileData
* @return 当前对象
*/
LambdaQueryPredicate exselects(String attrNameChain);
/**
* 添加排序,不指定排序方向,以数据库默认排序为准
* @param getterFns 实体类的getter函数式
* @return 当前对象
*/
@SuppressWarnings("unchecked")
LambdaQueryPredicate order(SerializableFunction... getterFns);
/**
* 添加排序,指定排序方向
* @param direction 排序方向枚举
* @param getterFn 实体类的getter函数式
* @return 当前对象
*/
LambdaQueryPredicate order(Direction direction, SerializableFunction getterFn);
/**
* 添加排序,指定排序方向
* @param direction 排序方向枚举
* @param getterFns 实体类的getter函数式
* @return 当前对象
*/
@SuppressWarnings("unchecked")
LambdaQueryPredicate order(Direction direction, SerializableFunction... getterFns);
/**
* 指定排序
* @param sort 排序
* @return 当前对象
*/
LambdaQueryPredicate order(Sort sort);
/**
* 添加升序排序
* @param getterFn 实体类的getter函数式
* @return 当前对象
*/
LambdaQueryPredicate orderAsc(SerializableFunction getterFn);
/**
* 添加升序排序
* @param getterFns 实体类的getter函数式
* @return 当前对象
*/
@SuppressWarnings("unchecked")
LambdaQueryPredicate orderAsc(SerializableFunction... getterFns);
/**
* 添加降序排序
* @param getterFn 实体类的getter函数式
* @return 当前对象
*/
LambdaQueryPredicate orderDesc(SerializableFunction getterFn);
/**
* 添加降序排序
* @param getterFns 实体类的getter函数式
* @return 当前对象
*/
@SuppressWarnings("unchecked")
LambdaQueryPredicate orderDesc(SerializableFunction... getterFns);
/**
* 获取第1页的pageSize条数据
* @param pageSize 每页行数
* @return 当前对象
*/
LambdaQueryPredicate limit(int pageSize);
/**
* 获取第1页的pageSize条数据
* @param pageSize 每页行数
* @param count 是否查询符合的总行数
* @return 当前对象
*/
LambdaQueryPredicate limit(int pageSize, boolean count);
/**
* 获取第pageNum页的pageSize条数据
* @param pageNum 起始页,从1开始
* @param pageSize 每页行数
* @return 当前对象
*/
LambdaQueryPredicate limit(int pageNum, int pageSize);
/**
*
* 获取第pageNum页的pageSize条数据
* @param pageNum 起始页,从1开始
* @param pageSize 每页行数
* @param count 是否查询符合的总行数
* @return 当前对象
*/
LambdaQueryPredicate limit(int pageNum, int pageSize, boolean count);
/**
* 使用一个Pageable对象传递分页信息
* @param page 分页,getPageNum()、getPageSize()值需大于0
* @return 当前对象
*/
LambdaQueryPredicate limit(Pageable page);
@Override
LambdaQueryPredicate apply(T entity);
@Override
LambdaQueryPredicate conditionMode(Mode conditionMode);
@Override
LambdaQueryPredicate and(Condition... conditions);
@Override
LambdaQueryPredicate and(Consumer> predicate);
@Override
LambdaQueryPredicate andP(Consumer predicate);
@Override
LambdaQueryPredicate or(Condition... conditions);
@Override
LambdaQueryPredicate or(Consumer> predicate);
@Override
LambdaQueryPredicate orP(Consumer predicate);
@Override
LambdaQueryPredicate not(Condition... conditions);
@Override
LambdaQueryPredicate not(Consumer> predicate);
@Override
LambdaQueryPredicate notP(Consumer predicate);
@Override
LambdaQueryPredicate eq(SerializableFunction fn);
@Override
LambdaQueryPredicate eq(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate neq(SerializableFunction fn);
@Override
LambdaQueryPredicate neq(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate lt(SerializableFunction fn);
@Override
LambdaQueryPredicate lt(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate lte(SerializableFunction fn);
@Override
LambdaQueryPredicate lte(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate gt(SerializableFunction fn);
@Override
LambdaQueryPredicate gt(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate gte(SerializableFunction fn);
@Override
LambdaQueryPredicate gte(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate like(SerializableFunction fn);
@Override
LambdaQueryPredicate like(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate notLike(SerializableFunction fn);
@Override
LambdaQueryPredicate notLike(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate contain(SerializableFunction fn);
@Override
LambdaQueryPredicate contain(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate notContain(SerializableFunction fn);
@Override
LambdaQueryPredicate notContain(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate startWith(SerializableFunction fn);
@Override
LambdaQueryPredicate startWith(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate endWith(SerializableFunction fn);
@Override
LambdaQueryPredicate endWith(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate between(SerializableFunction fn, Object startValue, Object endValue);
@Override
LambdaQueryPredicate between(boolean accept, SerializableFunction fn, Object startValue,
Object endValue);
@Override
LambdaQueryPredicate isNull(SerializableFunction fn);
@Override
LambdaQueryPredicate isNull(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate notNull(SerializableFunction fn);
@Override
LambdaQueryPredicate notNull(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate in(SerializableFunction fn);
@Override
LambdaQueryPredicate in(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate notIn(SerializableFunction fn);
@Override
LambdaQueryPredicate notIn(boolean accept, SerializableFunction fn);
@Override
LambdaQueryPredicate eq(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate eq(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate neq(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate neq(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate lt(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate lt(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate lte(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate lte(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate gt(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate gt(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate gte(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate gte(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate like(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate like(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate notLike(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate notLike(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate contain(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate contain(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate notContain(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate notContain(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate startWith(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate startWith(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate endWith(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate endWith(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate in(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate in(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate notIn(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate notIn(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate regex(SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate regex(boolean accept, SerializableFunction getterFn, Object value);
@Override
LambdaQueryPredicate undeleted();
@Override
LambdaQueryPredicate deleted();
/**
* 去除重复
* @return 当前对象
*/
LambdaQueryPredicate distinct();
/**
* 设置数据库锁模式
* @param lockModeType {@link LockModeType}锁模式
* 本框架下模式READ/WRITE/OPTIMISTIC/OPTIMISTIC_FORCE_INCREMENT都等同于NONE,即无锁,乐观锁是实体在声明{@link Version}之后自动使用的
* PESSIMISTIC_WRITE等于PESSIMISTIC_FORCE_INCREMENT,即使用悲观写锁,如果有{@link Version}声明属性,则自增。
* 如果数据库无读锁(共享锁)则PESSIMISTIC_READ跟PESSIMISTIC_WRITE功能一致
* @return 当前对象
*/
LambdaQueryPredicate lock(LockModeType lockModeType);
/**
* 设置数据库锁,并且锁模式为悲观写锁{@link LockModeType#PESSIMISTIC_WRITE}
* @return 当前对象
*/
LambdaQueryPredicate lock();
/**
* 设置全局联结模式
* @param joinMode 联结模式
* @return 当前对象
*/
LambdaQueryPredicate joinMode(JoinMode joinMode);
/**
* 设置关联属性的实体联结模式
* @param refGetterFn 实体类属性的getter函数式
* @param joinMode 联结模式
* @return 当前对象
*/
LambdaQueryPredicate joinMode(SerializableFunction refGetterFn, JoinMode joinMode);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy