All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.easy.query.api.proxy.entity.delete.abstraction.AbstractExpressionDeletable Maven / Gradle / Ivy

There is a newer version: 2.0.106
Show newest version
package com.easy.query.api.proxy.entity.delete.abstraction;

import com.easy.query.api.proxy.entity.delete.ExpressionDeletable;
import com.easy.query.core.basic.api.delete.ClientExpressionDeletable;
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.EntityDeleteExpressionBuilder;
import com.easy.query.core.expression.sql.builder.ExpressionContext;
import com.easy.query.core.expression.sql.builder.internal.ContextConfigurer;
import com.easy.query.core.expression.sql.builder.internal.EasyBehavior;
import com.easy.query.core.proxy.ProxyEntity;

import java.util.Collection;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * @author xuejiaming
 * @FileName: AbstractExpressionDelete.java
 * @Description: 文件说明
 * @Date: 2023/3/1 22:30
 */
public abstract class AbstractExpressionDeletable, T> implements ExpressionDeletable {
    private final TProxy tProxy;
    private final ClientExpressionDeletable expressionObjectDeletable;

    public AbstractExpressionDeletable(TProxy tProxy, ClientExpressionDeletable expressionObjectDeletable) {
        this.expressionObjectDeletable = expressionObjectDeletable;
        this.tProxy = tProxy.create(expressionObjectDeletable.getDeleteExpressionBuilder().getTable(0).getEntityTable(), expressionObjectDeletable.getDeleteExpressionBuilder(), getExpressionContext().getRuntimeContext());
    }

    @Override
    public EntityDeleteExpressionBuilder getDeleteExpressionBuilder() {
        return expressionObjectDeletable.getDeleteExpressionBuilder();
    }

    @Override
    public ExpressionContext getExpressionContext() {
        return expressionObjectDeletable.getExpressionContext();
    }

    @Override
    public long executeRows() {
        return expressionObjectDeletable.executeRows();
    }

//    @Override
//    public void executeRows(long expectRows, String msg, String code) {
//        long rows = executeRows();
//        if(rows!=expectRows){
//            throw new EasyQueryConcurrentException(msg,code);
//        }
//    }

    @Override
    public ExpressionDeletable where(boolean condition, SQLExpression1 whereExpression) {
        if (condition) {
            expressionObjectDeletable.where(where -> {
                tProxy.getEntitySQLContext()._where(where.getFilter(), () -> {
                    whereExpression.apply(tProxy);
                });
            });
        }
        return this;
    }

    @Override
    public ExpressionDeletable withVersion(boolean condition, Object versionValue) {
        if (condition) {
            expressionObjectDeletable.withVersion(versionValue);
        }
        return this;
    }

    @Override
    public ExpressionDeletable whereById(boolean condition, Object id) {

        if (condition) {
            expressionObjectDeletable.whereById(id);
        }
        return this;
    }

    @Override
    public  ExpressionDeletable whereByIds(boolean condition, Collection ids) {

        if (condition) {
            expressionObjectDeletable.whereByIds(ids);
        }
        return this;
    }

    @Override
    public ExpressionDeletable useLogicDelete(boolean enable) {
        expressionObjectDeletable.useLogicDelete(enable);
        return this;
    }

    @Override
    public ExpressionDeletable allowDeleteStatement(boolean allow) {
        expressionObjectDeletable.allowDeleteStatement(allow);
        return this;
    }

    @Override
    public ExpressionDeletable asTable(Function tableNameAs) {
        expressionObjectDeletable.asTable(tableNameAs);
        return this;
    }

    @Override
    public ExpressionDeletable asSchema(Function schemaAs) {
        expressionObjectDeletable.asSchema(schemaAs);
        return this;
    }

    @Override
    public ExpressionDeletable asAlias(String alias) {
        expressionObjectDeletable.asAlias(alias);
        return this;
    }

    @Override
    public String toSQL(ToSQLContext toSQLContext) {
        return expressionObjectDeletable.toSQL(toSQLContext);
    }

    @Override
    public ExpressionDeletable noInterceptor() {
        expressionObjectDeletable.noInterceptor();
        return this;
    }

    @Override
    public ExpressionDeletable useInterceptor(String name) {
        expressionObjectDeletable.useInterceptor(name);
        return this;
    }

    @Override
    public ExpressionDeletable noInterceptor(String name) {
        expressionObjectDeletable.noInterceptor(name);
        return this;
    }

    @Override
    public ExpressionDeletable useInterceptor() {
        expressionObjectDeletable.useInterceptor();
        return this;
    }

    @Override
    public ExpressionDeletable ignoreVersion(boolean ignored) {
        expressionObjectDeletable.ignoreVersion(ignored);
        return this;
    }

    @Override
    public void executeRows(long expectRows, String msg, String code) {
        expressionObjectDeletable.executeRows(expectRows, msg, code);
    }

    @Override
    public ExpressionDeletable asTableLink(Function linkAs) {
        expressionObjectDeletable.asTableLink(linkAs);
        return this;
    }

    @Override
    public ExpressionDeletable asTableSegment(BiFunction segmentAs) {
        expressionObjectDeletable.asTableSegment(segmentAs);
        return this;
    }

    @Override
    public ExpressionDeletable configure(SQLExpression1 configurer) {
        expressionObjectDeletable.configure(configurer);
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy