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

com.easy.query.api4j.update.EntityUpdatable Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
package com.easy.query.api4j.update;

import com.easy.query.api4j.sql.SQLColumnConfigurer;
import com.easy.query.api4j.sql.SQLColumnOnlySelector;
import com.easy.query.api4j.sql.impl.SQLColumnConfigurerImpl;
import com.easy.query.api4j.sql.impl.SQLColumnOnlySelectorImpl;
import com.easy.query.core.basic.api.internal.ConfigureVersionable;
import com.easy.query.core.basic.api.internal.SQLExecuteStrategy;
import com.easy.query.core.basic.api.update.ClientEntityUpdatable;
import com.easy.query.core.basic.api.update.Updatable;
import com.easy.query.core.expression.lambda.SQLExpression1;

/**
 * @author xuejiaming
 * @FileName: EntityUpdate.java
 * @Description: 文件说明
 * @Date: 2023/2/24 23:22
 */
public interface EntityUpdatable extends Updatable>, SQLExecuteStrategy>,
        ConfigureVersionable> {
    ClientEntityUpdatable getClientUpdate();
    default EntityUpdatable columnConfigure(SQLExpression1> columnConfigureExpression){
        getClientUpdate().columnConfigure(configurer->{
            columnConfigureExpression.apply(new SQLColumnConfigurerImpl<>(configurer));
        });
        return this;
    }

    /**
     * 只更新列
     * @param columnSelectorExpression
     * @return
     */
    default EntityUpdatable setColumns(SQLExpression1> columnSelectorExpression) {
        getClientUpdate().setColumns(selector -> {
            columnSelectorExpression.apply(new SQLColumnOnlySelectorImpl<>(selector));
        });
        return this;
    }

    default EntityUpdatable setColumns(boolean condition, SQLExpression1> columnSelectorExpression) {
        getClientUpdate().setColumns(condition, selector -> {
            columnSelectorExpression.apply(new SQLColumnOnlySelectorImpl<>(selector));
        });
        return this;
    }

    default EntityUpdatable setIgnoreColumns(SQLExpression1> columnSelectorExpression) {
        getClientUpdate().setIgnoreColumns(true, selector -> {
            columnSelectorExpression.apply(new SQLColumnOnlySelectorImpl<>(selector));
        });
        return this;
    }

    default EntityUpdatable setIgnoreColumns(boolean condition, SQLExpression1> columnSelectorExpression) {
        getClientUpdate().setIgnoreColumns(condition, selector -> {
            columnSelectorExpression.apply(new SQLColumnOnlySelectorImpl<>(selector));
        });
        return this;
    }

    default EntityUpdatable whereColumns(SQLExpression1> columnSelectorExpression) {
        getClientUpdate().whereColumns(selector -> {
            columnSelectorExpression.apply(new SQLColumnOnlySelectorImpl<>(selector));
        });
        return this;
    }

    default EntityUpdatable whereColumns(boolean condition, SQLExpression1> columnSelectorExpression) {
        getClientUpdate().whereColumns(condition, selector -> {
            columnSelectorExpression.apply(new SQLColumnOnlySelectorImpl<>(selector));
        });
        return this;
    }
    default String toSQL(Object entity) {
        return getClientUpdate().toSQL(entity);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy