Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.easy.query.api4j.sql.SQLColumnAsSelector Maven / Gradle / Ivy
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.core.available.LambdaSQLFuncAvailable;
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.func.ACSSelector;
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, LambdaSQLFuncAvailable, SQLAsLambdaNative> {
ColumnAsSelector getColumnAsSelector();
default QueryRuntimeContext getRuntimeContext() {
return getColumnAsSelector().getRuntimeContext();
}
default ExpressionContext getExpressionContext() {
return getColumnAsSelector().getExpressionContext();
}
default TableAvailable getTable() {
return getColumnAsSelector().getTable();
}
/**
* 从group的列里面快速获取对应的列
*
* @param index
* @return
*/
default SQLColumnAsSelector groupKeys(int index) {
getColumnAsSelector().groupKeys(index);
return this;
}
default SQLColumnAsSelector groupKeysAs(int index, Property alias) {
getColumnAsSelector().groupKeysAs(index, EasyLambdaUtil.getPropertyName(alias));
return this;
}
default SQLColumnAsSelector groupKeysAs(int index, String alias) {
getColumnAsSelector().groupKeysAs(index, alias);
return this;
}
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);
}
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);
}
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;
}
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));
}
/**
* 如果是map结果或者基本类型那么alias就是别名
* 如果是其他情况则为TR类型的属性名
*
* @param column
* @param alias
* @return
*/
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 columnCount(Property column, SQLExpression1 sqlExpression) {
getColumnAsSelector().columnCount(EasyLambdaUtil.getPropertyName(column), sqlExpression);
return this;
}
default SQLColumnAsSelector columnCountAs(Property column, Property alias) {
getColumnAsSelector().columnCountAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias));
return this;
}
default SQLColumnAsSelector columnCountAs(Property column, Property alias, SQLExpression1 sqlExpression) {
getColumnAsSelector().columnCountAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias), sqlExpression);
return this;
}
/**
* columnSum(BlogEntity::getScore) SUM(t.`score`)
* columnSum(BlogEntity::getScore,c->c.distinct(true)) SUM(DISTINCT t.`score`)
* columnSum(BlogEntity::getScore,c->c.nullDefault(BigDecimal.ZERO)) SUM(IFNULL(t.`score`,?))
* columnSum(BlogEntity::getScore,c->c.distinct(true).nullDefault(BigDecimal.ZERO)) SUM(DISTINCT IFNULL(t.`score`,?))
*
* @param column 属性列
* @return 当前列选择器
*/
default SQLColumnAsSelector columnSum(Property column) {
getColumnAsSelector().columnSum(EasyLambdaUtil.getPropertyName(column));
return this;
}
/**
* columnSum(BlogEntity::getScore) SUM(t.`score`)
* columnSum(BlogEntity::getScore,c->c.distinct(true)) SUM(DISTINCT t.`score`)
* columnSum(BlogEntity::getScore,c->c.nullDefault(BigDecimal.ZERO)) SUM(IFNULL(t.`score`,?))
* columnSum(BlogEntity::getScore,c->c.distinct(true).nullDefault(BigDecimal.ZERO)) SUM(DISTINCT IFNULL(t.`score`,?))
*
* @param column 属性列
* @param sqlExpression distinct|null default
* @return 当前列选择器
*/
default SQLColumnAsSelector columnSum(Property column, SQLExpression1 sqlExpression) {
getColumnAsSelector().columnSum(EasyLambdaUtil.getPropertyName(column), sqlExpression);
return this;
}
/**
* columnSum(BlogEntity::getScore) SUM(t.`score`)
* columnSum(BlogEntity::getScore,c->c.distinct(true)) SUM(DISTINCT t.`score`)
* columnSum(BlogEntity::getScore,c->c.nullDefault(BigDecimal.ZERO)) SUM(IFNULL(t.`score`,?))
* columnSum(BlogEntity::getScore,c->c.distinct(true).nullDefault(BigDecimal.ZERO)) SUM(DISTINCT IFNULL(t.`score`,?))
*
* @param column 属性列
* @param alias 别名
* @return 当前列选择器
*/
default SQLColumnAsSelector columnSumAs(Property column, Property alias) {
getColumnAsSelector().columnSumAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias));
return this;
}
/**
* {@code columnSum(BlogEntity::getScore) SUM(t.`score`)}
*
* {@code columnSum(BlogEntity::getScore,c->c.distinct(true)) SUM(DISTINCT t.`score`)}
*
* {@code columnSum(BlogEntity::getScore,c->c.nullDefault(BigDecimal.ZERO)) SUM(IFNULL(t.`score`,?))}
*
* {@code columnSum(BlogEntity::getScore,c->c.distinct(true).nullDefault(BigDecimal.ZERO)) SUM(DISTINCT IFNULL(t.`score`,?))}
*
* @param column 属性列
* @param alias 别名
* @param sqlExpression distinct|null default
* @return 当前列选择器
*/
default SQLColumnAsSelector columnSumAs(Property column, Property alias, SQLExpression1 sqlExpression) {
getColumnAsSelector().columnSumAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias), sqlExpression);
return this;
}
default SQLColumnAsSelector columnMax(Property column) {
getColumnAsSelector().columnMax(EasyLambdaUtil.getPropertyName(column));
return this;
}
default SQLColumnAsSelector columnMaxAs(Property column, Property alias) {
getColumnAsSelector().columnMaxAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias));
return this;
}
default SQLColumnAsSelector columnMin(Property column) {
getColumnAsSelector().columnMin(EasyLambdaUtil.getPropertyName(column));
return this;
}
default SQLColumnAsSelector columnMinAs(Property column, Property alias) {
getColumnAsSelector().columnMinAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias));
return this;
}
default SQLColumnAsSelector columnAvg(Property column) {
getColumnAsSelector().columnAvg(EasyLambdaUtil.getPropertyName(column));
return this;
}
default SQLColumnAsSelector columnAvg(Property column, SQLExpression1 sqlExpression) {
getColumnAsSelector().columnAvg(EasyLambdaUtil.getPropertyName(column), sqlExpression);
return this;
}
default SQLColumnAsSelector columnAvgAs(Property column, Property alias) {
getColumnAsSelector().columnAvgAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias));
return this;
}
default SQLColumnAsSelector columnAvgAs(Property column, Property alias, SQLExpression1 sqlExpression) {
getColumnAsSelector().columnAvgAs(EasyLambdaUtil.getPropertyName(column), EasyLambdaUtil.getPropertyName(alias), sqlExpression);
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;
}
}