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

com.easy.query.api4j.sql.SQLColumnAsSelector Maven / Gradle / Ivy

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

import com.easy.query.api4j.select.Queryable;
import com.easy.query.api4j.sql.core.SQLAsLambdaNative;
import com.easy.query.api4j.sql.impl.SQLColumnAsSelectorImpl;
import com.easy.query.api4j.util.EasyLambdaUtil;
import com.easy.query.core.context.QueryRuntimeContext;
import com.easy.query.core.expression.func.ColumnPropertyFunction;
import com.easy.query.core.expression.lambda.Property;
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLFuncExpression;
import com.easy.query.core.expression.parser.core.EntitySQLTableOwner;
import com.easy.query.core.expression.parser.core.available.TableAvailable;
import com.easy.query.core.expression.parser.core.base.ColumnAsSelector;
import com.easy.query.core.expression.segment.CloneableSQLSegment;
import com.easy.query.core.expression.sql.builder.ExpressionContext;
import com.easy.query.core.util.EasyCollectionUtil;

import java.util.Collection;

/**
 * @author xuejiaming
 * @Description: 文件说明
 * @Date: 2023/2/6 22:58
 */
public interface SQLColumnAsSelector extends EntitySQLTableOwner, SQLAsLambdaNative> {
    ColumnAsSelector getColumnAsSelector();

    default QueryRuntimeContext getRuntimeContext() {
        return getColumnAsSelector().getRuntimeContext();
    }

    default ExpressionContext getExpressionContext() {
        return getColumnAsSelector().getExpressionContext();
    }

    default TableAvailable getTable() {
        return getColumnAsSelector().getTable();
    }

    default  SQLColumnAsSelector columns(Collection> columns) {
        if(EasyCollectionUtil.isNotEmpty(columns)){
            for (Property column : columns) {
                this.column(column);
            }
        }
        return this;
    }

    default  SQLColumnAsSelector column(Property column) {
        getColumnAsSelector().column(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default  SQLColumnAsSelector columnInclude(Property column, Property aliasProperty) {
        return columnInclude(true, column, aliasProperty, SQLColumnAsSelector::columnAll);
    }

    default  SQLColumnAsSelector columnInclude(boolean condition, Property column, Property aliasProperty) {
        return columnInclude(condition, column, aliasProperty, SQLColumnAsSelector::columnAll);
    }

    default  SQLColumnAsSelector columnInclude(Property column, Property aliasProperty, SQLExpression1> includeSelectorExpression) {
        return columnInclude(true, column, aliasProperty, includeSelectorExpression);
    }

    default  SQLColumnAsSelector columnInclude(boolean condition, Property column, Property aliasProperty, SQLExpression1> includeSelectorExpression) {
        if (condition) {
            getColumnAsSelector().columnInclude(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(aliasProperty), columnAsSelect -> {
                includeSelectorExpression.apply(new SQLColumnAsSelectorImpl<>(columnAsSelect));
            });
        }
        return this;
    }

    default  SQLColumnAsSelector columnIncludeMany(Property> column, Property> aliasProperty) {
        return columnIncludeMany(true, column, aliasProperty, SQLColumnAsSelector::columnAll);
    }

    default  SQLColumnAsSelector columnIncludeMany(boolean condition, Property> column, Property> aliasProperty) {
        return columnIncludeMany(condition, column, aliasProperty, SQLColumnAsSelector::columnAll);
    }

    default  SQLColumnAsSelector columnIncludeMany(Property> column, Property> aliasProperty, SQLExpression1> includeSelectorExpression) {
        return columnIncludeMany(true, column, aliasProperty, includeSelectorExpression);
    }

    default  SQLColumnAsSelector columnIncludeMany(boolean condition, Property> column, Property> aliasProperty, SQLExpression1> includeSelectorExpression) {
        if (condition) {
            getColumnAsSelector().columnInclude(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(aliasProperty), columnAsSelect -> {
                includeSelectorExpression.apply(new SQLColumnAsSelectorImpl<>(columnAsSelect));
            });
        }
        return this;
    }

    /**
     * 请使用 sqlNativeSegment
     *
     * @param columnConst
     * @return
     */
    @Deprecated
    default SQLColumnAsSelector columnConst(String columnConst) {
        return sqlNativeSegment(columnConst, c -> {
        });
    }

    default SQLColumnAsSelector columnIgnore(Property column) {
        getColumnAsSelector().columnIgnore(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    /**
     * 映射到TR的所有列上,按ColumnName进行映射,如果TR上没有对应的列名那么将不会映射查询列
     *
     * @return
     */
    default SQLColumnAsSelector columnAll() {
        getColumnAsSelector().columnAll();
        return this;
    }

    default SQLColumnAsSelector columnAs(Property column, Property alias) {
        return columnAs(column, EasyLambdaUtil.getPropertyName(alias));
    }


    default SQLColumnAsSelector columnAs(Property column, String alias) {
        getColumnAsSelector().columnAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default  SQLColumnAsSelector columnSubQueryAs(SQLFuncExpression> subQueryableFunc, String alias) {
        getColumnAsSelector().columnSubQueryAs(subQueryableFunc::apply, alias);
        return this;
    }

    default  SQLColumnAsSelector columnSubQueryAs(SQLFuncExpression> subQueryableFunc, Property alias) {
        return columnSubQueryAs(subQueryableFunc, EasyLambdaUtil.getPropertyName(alias));
    }

//    default  SQLColumnAsSelector columnSubQueryAs(SQLFuncExpression2,SQLWherePredicate, Queryable> subQueryableFunc, Property alias) {
//        return columnSubQueryAs(subQueryableFunc, EasyLambdaUtil.getPropertyName(alias));
//    }

    default SQLColumnAsSelector columnCount(Property column) {
        getColumnAsSelector().columnCount(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnCountAs(Property column, String alias) {
        getColumnAsSelector().columnCountAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnCountAs(Property column, Property alias) {
        return columnCountAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnCountDistinct(Property column) {
        getColumnAsSelector().columnCountDistinct(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnCountDistinctAs(Property column, String alias) {
        getColumnAsSelector().columnCountDistinctAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnCountDistinctAs(Property column, Property alias) {
        return columnCountDistinctAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnSum(Property column) {
        getColumnAsSelector().columnSum(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnSumAs(Property column, Property alias) {
        return columnSumAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnSumAs(Property column, String alias) {
        getColumnAsSelector().columnSumAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnSumDistinct(Property column) {
        getColumnAsSelector().columnSumDistinct(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnSumDistinctAs(Property column, Property alias) {
        return columnSumDistinctAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnSumDistinctAs(Property column, String alias) {
        getColumnAsSelector().columnSumDistinctAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnMax(Property column) {
        getColumnAsSelector().columnMax(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnMaxAs(Property column, Property alias) {
        return columnMaxAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnMaxAs(Property column, String alias) {
        getColumnAsSelector().columnMaxAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnMin(Property column) {
        getColumnAsSelector().columnMin(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnMinAs(Property column, Property alias) {
        return columnMinAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnMinAs(Property column, String alias) {
        getColumnAsSelector().columnMinAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnAvg(Property column) {
        getColumnAsSelector().columnAvg(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnAvgAs(Property column, Property alias) {
        return columnAvgAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnAvgAs(Property column, String alias) {
        getColumnAsSelector().columnAvgAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnAvgDistinct(Property column) {
        getColumnAsSelector().columnAvgDistinct(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnAvgDistinctAs(Property column, Property alias) {
        return columnAvgDistinctAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnAvgDistinctAs(Property column, String alias) {
        getColumnAsSelector().columnAvgDistinctAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnLen(Property column) {
        getColumnAsSelector().columnLen(EasyLambdaUtil.getPropertyName(column));
        return this;
    }

    default SQLColumnAsSelector columnLenAs(Property column, Property alias) {
        return columnLenAs(column, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnLenAs(Property column, String alias) {
        getColumnAsSelector().columnLenAs(EasyLambdaUtil.getPropertyName(column), alias);
        return this;
    }

    default SQLColumnAsSelector columnFuncAs(ColumnPropertyFunction columnPropertyFunction, Property alias) {
        return columnFuncAs(columnPropertyFunction, EasyLambdaUtil.getPropertyName(alias));
    }

    default SQLColumnAsSelector columnFuncAs(ColumnPropertyFunction columnPropertyFunction, String alias) {
        getColumnAsSelector().columnFuncAs(columnPropertyFunction, alias);
        return this;
    }

    default SQLColumnAsSelector sqlSegmentAs(CloneableSQLSegment sqlColumnSegment, Property alias) {
        getColumnAsSelector().sqlSegmentAs(sqlColumnSegment, EasyLambdaUtil.getPropertyName(alias));
        return this;
    }

    default  SQLColumnAsSelector then(SQLColumnAsSelector sub) {
        getColumnAsSelector().then(sub.getColumnAsSelector());
        return sub;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy