com.easy.query.api.proxy.entity.update.ExpressionUpdatable Maven / Gradle / Ivy
package com.easy.query.api.proxy.entity.update;
import com.easy.query.core.basic.api.internal.ConfigureVersionable;
import com.easy.query.core.basic.api.internal.WithVersionable;
import com.easy.query.core.basic.api.update.ClientExpressionUpdatable;
import com.easy.query.core.basic.api.update.Updatable;
import com.easy.query.core.basic.jdbc.parameter.ToSQLContext;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.sql.builder.ExpressionContext;
import com.easy.query.core.proxy.ProxyEntity;
import java.util.Collection;
/**
* @author xuejiaming
* @FileName: ExpressionUpdatable.java
* @Description: 文件说明
* @Date: 2023/2/24 23:21
*/
public interface ExpressionUpdatable, T> extends Updatable>, WithVersionable>, ConfigureVersionable> {
TProxy getProxy();
ClientExpressionUpdatable getClientUpdate();
default ExpressionUpdatable setColumns(SQLExpression1 columnSetExpression) {
return setColumns(true,columnSetExpression);
}
default ExpressionUpdatable setColumns(boolean condition, SQLExpression1 columnSetExpression) {
if(condition){
getProxy().getEntitySQLContext()._set(getClientUpdate().getColumnSetter().getSetter(),()->{
columnSetExpression.apply(getProxy());
});
}
return this;
}
/**
* where(o->o.id().eq())
* where(o->{
* o.id().eq(1);
* o.title().eq(2);
* })
*
* @param whereExpression
* @return
*/
default ExpressionUpdatable where(SQLExpression1 whereExpression) {
return where(true,whereExpression);
}
/**
* where(condition,o->o.id().eq())
* where(condition,o->{
* o.id().eq(1);
* o.title().eq(2);
* })
* @param condition
* @param whereExpression
* @return
*/
default ExpressionUpdatable where(boolean condition, SQLExpression1 whereExpression) {
if(condition){
getClientUpdate().where(true,where -> {
getProxy().getEntitySQLContext()._where(where.getFilter(),()->{
whereExpression.apply(getProxy());
});
});
}
return this;
}
default ExpressionUpdatable whereById(Object id) {
getClientUpdate().whereById(id);
return this;
}
default ExpressionUpdatable whereById(boolean condition, Object id) {
getClientUpdate().whereById(condition, id);
return this;
}
default ExpressionUpdatable whereByIds(Collection ids) {
getClientUpdate().whereByIds(ids);
return this;
}
default ExpressionUpdatable whereByIds(boolean condition, Collection ids) {
getClientUpdate().whereByIds(condition, ids);
return this;
}
default ExpressionContext getExpressionContext() {
return getClientUpdate().getExpressionContext();
}
default String toSQL() {
return getClientUpdate().toSQL();
}
default String toSQL(ToSQLContext toSQLContext) {
return getClientUpdate().toSQL(toSQLContext);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy