io.github.biezhi.anima.core.JoinParam Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anima Show documentation
Show all versions of anima Show documentation
Operate the database like a stream
package io.github.biezhi.anima.core;
import io.github.biezhi.anima.Model;
import io.github.biezhi.anima.core.functions.TypeFunction;
import io.github.biezhi.anima.enums.OrderBy;
import io.github.biezhi.anima.utils.AnimaUtils;
import lombok.Data;
/**
* @author biezhi
* @date 2018/4/16
*/
@Data
public class JoinParam {
private Class extends Model> joinModel;
private String onLeft;
private String onRight;
private String fieldName;
private String orderBy;
public JoinParam(Class extends Model> joinModel) {
this.joinModel = joinModel;
}
public JoinParam as(TypeFunction function) {
String fieldName = AnimaUtils.getLambdaColumnName(function);
this.setFieldName(fieldName);
return this;
}
public JoinParam on(TypeFunction left, TypeFunction right) {
String onLeft = AnimaUtils.getLambdaColumnName(left);
String onRight = AnimaUtils.getLambdaColumnName(right);
this.setOnLeft(onLeft);
this.setOnRight(onRight);
return this;
}
public JoinParam order(TypeFunction rightField, OrderBy orderBy) {
String columnName = AnimaUtils.getLambdaColumnName(rightField);
this.orderBy = columnName + " " + orderBy.name();
return this;
}
public JoinParam order(String orderBy) {
this.orderBy = orderBy;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy