Skip to content

Commit

Permalink
优化大量代码,添加大量单元测试 0.9.37
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed Jun 8, 2023
1 parent 61cb3a5 commit c51d3da
Show file tree
Hide file tree
Showing 47 changed files with 1,754 additions and 893 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ QQ群:170029046
```xml

<properties>
<easy-query.version>0.9.36</easy-query.version>
<easy-query.version>0.9.37</easy-query.version>
</properties>
<dependency>
<groupId>com.easy-query</groupId>
Expand All @@ -65,7 +65,7 @@ QQ群:170029046
```xml

<properties>
<easy-query.version>0.9.36</easy-query.version>
<easy-query.version>0.9.37</easy-query.version>
</properties>
<!-- 提供了以java语法强类型,如果不引用也可以使用只是无法使用lambda表达式来表示属性只能用字符串 -->
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<packaging>pom</packaging>
<version>0.9.36</version>
<version>0.9.37</version>
<name>easy-query</name>
<description>java object query distributed connector</description>
<url>https://github.com/xuejmnet/easy-query</url>
Expand All @@ -33,8 +33,8 @@
<module>sql-db-support/sql-pgsql</module>
<module>sql-db-support/sql-sqlite</module>
<!-- 以下是不需要deploy到远程仓库的-->
<!-- <module>sql-test</module>-->
<!-- <module>samples</module>-->
<module>sql-test</module>
<module>samples</module>
</modules>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.36</version>
<version>0.9.37</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion samples/springbootdemo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>com.easy-query</groupId>
<artifactId>sql-springboot-starter</artifactId>
<version>0.9.36</version>
<version>0.9.37</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
Expand Down
2 changes: 1 addition & 1 deletion sql-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.36</version>
<version>0.9.37</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public <T> ClientQueryable<T> queryable(Class<T> clazz) {
return easySQLApiFactory.createQueryable(clazz, runtimeContext);
}

@Override
public <T> ClientQueryable<T> queryable(ClientQueryable<T> queryable) {
return null;
}

@Override
public <T> ClientQueryable<T> queryable(String sql, Class<T> clazz) {
return easySQLApiFactory.createQueryable(sql, clazz, runtimeContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ default long sqlExecute(String sql) {

<T> ClientQueryable<T> queryable(Class<T> clazz);

<T> ClientQueryable<T> queryable(ClientQueryable<T> queryable);

<T> ClientQueryable<T> queryable(String sql, Class<T> clazz);

default Transaction beginTransaction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public <T> ClientQueryable<T> createQueryable(Class<T> clazz, QueryRuntimeContex
EntityQueryExpressionBuilder entityQueryExpressionBuilder = expressionBuilderFactory.createEntityQueryExpressionBuilder(queryExpressionContext);
EntityMetadata entityMetadata = runtimeContext.getEntityMetadataManager().getEntityMetadata(clazz);
int tableIndex = EasyUtil.getNextTableIndex(entityQueryExpressionBuilder);
;
EntityTableExpressionBuilder sqlTable = expressionBuilderFactory.createEntityTableExpressionBuilder(entityMetadata, tableIndex, MultiTableTypeEnum.FROM, runtimeContext);
entityQueryExpressionBuilder.addSQLEntityTableExpression(sqlTable);
return new EasyClientQueryable<>(clazz, entityQueryExpressionBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ default BigDecimal sumBigDecimalOrNull(String property) {
return sumBigDecimalOrDefault(property, null);
}

/**
* 防止溢出
*
* @param property
* @return
*/
default <TMember extends Number> BigDecimal sumBigDecimalNotNull(String property) {
return sumBigDecimalOrDefault(property, BigDecimal.ZERO);
}

<TMember extends Number> BigDecimal sumBigDecimalOrDefault(String property, BigDecimal def);

default <TMember extends Number> TMember sumOrNull(String property) {
Expand Down Expand Up @@ -120,13 +110,6 @@ default <TMember extends Number> Float avgOrDefault(String property, Float def)

<TMember extends Number, TResult extends Number> TResult avgOrDefault(String property, TResult def, Class<TResult> resultClass);

default Integer lenOrNull(String property) {
return lenOrDefault(property, null);
}

Integer lenOrDefault(String property, Integer def);


/**
* 对当前表达式返回自定义select列
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression2;
import com.easy.query.core.expression.lambda.SQLExpression3;
import com.easy.query.core.expression.parser.core.base.ColumnAsSelector;
import com.easy.query.core.expression.parser.core.base.ColumnResultSelector;
import com.easy.query.core.expression.parser.core.base.ColumnSelector;
import com.easy.query.core.expression.parser.core.base.GroupBySelector;
import com.easy.query.core.expression.parser.core.base.WherePredicate;
import com.easy.query.core.expression.parser.core.base.*;

import java.math.BigDecimal;
import java.util.function.Function;
Expand Down Expand Up @@ -75,17 +71,6 @@ default <TMember extends Number> BigDecimal sumBigDecimalOrNull(SQLExpression2<C
return sumBigDecimalOrDefault(columnSelectorExpression, null);
}

/**
* 防止溢出
*
* @param columnSelectorExpression
* @param <TMember>
* @return
*/
default <TMember extends Number> BigDecimal sumBigDecimalNotNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
return sumBigDecimalOrDefault(columnSelectorExpression, BigDecimal.ZERO);
}

<TMember extends Number> BigDecimal sumBigDecimalOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, BigDecimal def);

default <TMember extends Number> TMember sumOrNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
Expand All @@ -106,17 +91,31 @@ default <TMember> TMember minOrNull(SQLExpression2<ColumnResultSelector<T1>, Col

<TMember> TMember minOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, TMember def);

default <TMember extends Number> TMember avgOrNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null);
default <TMember extends Number> Double avgOrNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null, Double.class);
}

default <TMember extends Number> BigDecimal avgBigDecimalOrNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null, BigDecimal.class);
}

default <TMember extends Number> Float avgFloatOrNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null, Float.class);
}

default <TMember extends Number> Double avgOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, Double def) {
return avgOrDefault(columnSelectorExpression, def, Double.class);
}

<TMember extends Number> TMember avgOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, TMember def);
default <TMember extends Number> BigDecimal avgBigDecimalOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, BigDecimal def) {
return avgOrDefault(columnSelectorExpression, def, BigDecimal.class);
}

default Integer lenOrNull(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression) {
return lenOrDefault(columnSelectorExpression, null);
default <TMember extends Number> Float avgFloatOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, Float def) {
return avgOrDefault(columnSelectorExpression, def, Float.class);
}

Integer lenOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, Integer def);
<TMember extends Number, TResult extends Number> TResult avgOrDefault(SQLExpression2<ColumnResultSelector<T1>, ColumnResultSelector<T2>> columnSelectorExpression, TResult def, Class<TResult> resultClass);
//endregion

//region group
Expand All @@ -134,6 +133,20 @@ default ClientQueryable2<T1, T2> groupBy(SQLExpression2<GroupBySelector<T1>, Gro

ClientQueryable2<T1, T2> groupBy(boolean condition, SQLExpression2<GroupBySelector<T1>, GroupBySelector<T2>> selectExpression);

@Override
default ClientQueryable2<T1, T2> having(SQLExpression1<WhereAggregatePredicate<T1>> predicateExpression) {
return having(true, predicateExpression);
}

@Override
ClientQueryable2<T1, T2> having(boolean condition, SQLExpression1<WhereAggregatePredicate<T1>> predicateExpression);

default ClientQueryable2<T1, T2> having(SQLExpression2<WhereAggregatePredicate<T1>, WhereAggregatePredicate<T2>> predicateExpression) {
return having(true, predicateExpression);
}

ClientQueryable2<T1, T2> having(boolean condition, SQLExpression2<WhereAggregatePredicate<T1>, WhereAggregatePredicate<T2>> predicateExpression);

//endregion
//region order
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import com.easy.query.core.expression.lambda.SQLExpression1;
import com.easy.query.core.expression.lambda.SQLExpression3;
import com.easy.query.core.expression.lambda.SQLExpression4;
import com.easy.query.core.expression.parser.core.base.ColumnAsSelector;
import com.easy.query.core.expression.parser.core.base.ColumnResultSelector;
import com.easy.query.core.expression.parser.core.base.ColumnSelector;
import com.easy.query.core.expression.parser.core.base.GroupBySelector;
import com.easy.query.core.expression.parser.core.base.WherePredicate;
import com.easy.query.core.expression.parser.core.base.*;

import java.math.BigDecimal;
import java.util.function.Function;
Expand Down Expand Up @@ -76,17 +72,6 @@ default <TMember extends Number> BigDecimal sumBigDecimalOrNull(SQLExpression3<C
return sumBigDecimalOrDefault(columnSelectorExpression, null);
}

/**
* 防止溢出
*
* @param columnSelectorExpression
* @param <TMember>
* @return
*/
default <TMember extends Number> BigDecimal sumBigDecimalNotNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
return sumBigDecimalOrDefault(columnSelectorExpression, BigDecimal.ZERO);
}

<TMember extends Number> BigDecimal sumBigDecimalOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, BigDecimal def);

default <TMember extends Number> TMember sumOrNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
Expand All @@ -107,17 +92,32 @@ default <TMember> TMember minOrNull(SQLExpression3<ColumnResultSelector<T1>, Col

<TMember> TMember minOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, TMember def);

default <TMember> TMember avgOrNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null);
default <TMember extends Number> Double avgOrNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null, Double.class);
}

default <TMember extends Number> BigDecimal avgBigDecimalOrNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null, BigDecimal.class);
}

default <TMember extends Number> Float avgFloatOrNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
return avgOrDefault(columnSelectorExpression, null, Float.class);
}

<TMember> TMember avgOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, TMember def);
default <TMember extends Number> Double avgOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, Double def) {
return avgOrDefault(columnSelectorExpression, def, Double.class);
}

default <TMember extends Number> BigDecimal avgBigDecimalOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, BigDecimal def) {
return avgOrDefault(columnSelectorExpression, def, BigDecimal.class);
}

default Integer lenOrNull(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression) {
return lenOrDefault(columnSelectorExpression, null);
default <TMember extends Number> Float avgFloatOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, Float def) {
return avgOrDefault(columnSelectorExpression, def, Float.class);
}

Integer lenOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, Integer def);
<TMember extends Number, TResult extends Number> TResult avgOrDefault(SQLExpression3<ColumnResultSelector<T1>, ColumnResultSelector<T2>, ColumnResultSelector<T3>> columnSelectorExpression, TResult def, Class<TResult> resultClass);

//endregion

//region group
Expand All @@ -135,6 +135,21 @@ default ClientQueryable3<T1, T2, T3> groupBy(SQLExpression3<GroupBySelector<T1>,

ClientQueryable3<T1, T2, T3> groupBy(boolean condition, SQLExpression3<GroupBySelector<T1>, GroupBySelector<T2>, GroupBySelector<T3>> selectExpression);


@Override
default ClientQueryable3<T1, T2, T3> having(SQLExpression1<WhereAggregatePredicate<T1>> predicateExpression) {
return having(true, predicateExpression);
}

@Override
ClientQueryable3<T1, T2, T3> having(boolean condition, SQLExpression1<WhereAggregatePredicate<T1>> predicateExpression);

default ClientQueryable3<T1, T2, T3> having(SQLExpression3<WhereAggregatePredicate<T1>, WhereAggregatePredicate<T2>, WhereAggregatePredicate<T3>> predicateExpression) {
return having(true, predicateExpression);
}

ClientQueryable3<T1, T2, T3> having(boolean condition, SQLExpression3<WhereAggregatePredicate<T1>, WhereAggregatePredicate<T2>, WhereAggregatePredicate<T3>> predicateExpression);

//endregion
//region order
@Override
Expand Down
Loading

0 comments on commit c51d3da

Please sign in to comment.