com.zys.mybatis.crud.base.Condition Maven / Gradle / Ivy
package com.zys.mybatis.crud.base;
import com.zys.mybatis.crud.AbstractQuery;
import com.zys.mybatis.crud.Query;
import com.zys.mybatis.crud.SFunction;
import com.zys.mybatis.page.BasePage;
import com.zys.mybatis.utils.FieldUtils;
import com.zys.mybatis.utils.LambdaUtils;
/**
* 关联条件查询
* @author zys
* @date 2022/3/9 11:25
*/
public class Condition extends AbstractQuery> {
private final Query query;
public Query getQuery() {
return query;
}
/**
* 复杂条件构造器
* @param tClass 返回实体
* @param column 查询字段
*/
public Condition(Class tClass, SFunction column) {
this.query = new Query<>(tClass, FieldUtils.getColumn(LambdaUtils.resolve(column)));
}
public Condition orderBy(boolean condition, String... sort) {
query.orderBy(condition, sort);
return this;
}
public Condition orderBy(Order... order) {
query.orderBy(order);
return this;
}
public Condition orderBy(boolean condition, Order... order) {
query.orderBy(condition, order);
return this;
}
public Condition limit(Integer index, Integer pageSize) {
query.limit(index, pageSize);
return this;
}
public Condition limit(Integer pageSize) {
query.limit(pageSize);
return this;
}
public Condition limit(BasePage basePage) {
query.limit(basePage);
return this;
}
public Condition groupBy(boolean flag, String... fields) {
query.groupBy(flag, fields);
return this;
}
public Condition groupBy(SFunction... fields) {
query.groupBy(fields);
return this;
}
public Condition groupBy(boolean flag, SFunction... fields) {
query.groupBy(flag, fields);
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy