Skip to content

Commit

Permalink
dependence upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
huangxiaohu committed May 18, 2022
1 parent 322f74b commit 7a60cee
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 17 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ allprojects {
maven {
url 'https://repo.huaweicloud.com/repository/maven/'
}
mavenCentral()
}
buildscript {
repositories {
Expand Down Expand Up @@ -71,7 +72,7 @@ dependencies {
implementation 'org.springframework:spring-web:5.3.14'
implementation 'org.hibernate:hibernate-core:5.6.8.Final'
implementation 'com.github.vertical-blank:sql-formatter:2.0.3'
implementation 'com.sondertara:common-tara:0.0.4.0'
implementation 'com.sondertara:common-tara:0.1.0'
compileOnly 'org.projectlombok:lombok:1.18.24'
compileOnly 'com.oracle.database.jdbc:ojdbc8:21.5.0.0'

Expand Down
29 changes: 21 additions & 8 deletions src/main/java/com/sondertara/joya/core/builder/ExtPartBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,40 @@
public interface ExtPartBuilder extends SetupBuilder {

/**
* groupBy
* group by
*
* @param groupBySegment param
* @return the builder
*/
ExtPartBuilder groupBy(String groupBySegment);

/**
* having
* 使用方式: nativeSql.having(h -> h.eq().ne().in())
* <p>
* example:nativeSql.having(h -> h.eq().ne().in())
*
* @param func the function
* @return the builder
*/
ExtPartBuilder having(UnaryOperator<WhereCriterion> func);

/**
* orderBy
* 排序参数如果是前端传进来,用QueryRequest接收的 ===> nativeSql.orderBy( queryRequest.getOrderBy(表别名) )
* 手写逻辑指定排序字段 ==> nativeSql.orderBy("su.age asc")
* order by with function
* <p>
* example: nativeSql.orderBy("su.age asc")
*
* @param fn the column function
* @param orderBy the order type
* @param <T> the type of table class
* @return the builder
*/
<T> ExtPartBuilder orderBy(TaraFunction<T, ?> fn, OrderParam.OrderBy orderBy);

/**
* orderBy
* 排序参数如果是前端传进来,用QueryRequest接收的 ===> nativeSql.orderBy( queryRequest.getOrderBy(表别名) )
* 手写逻辑指定排序字段 ==> nativeSql.orderBy("su.age asc")
* order by with string
*
* @param orderBySegment order by params
* @return the builder
*/
ExtPartBuilder orderBy(String... orderBySegment);
}
13 changes: 11 additions & 2 deletions src/main/java/com/sondertara/joya/core/builder/FromBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
public interface FromBuilder {

/**
* 字符串格式的from语句
* from 要查询的表以及关联表
* sql from part with string
*
* @param tableAndJoinTable the sql from segment
* @return the next builder
*/
WhereBuilder from(String... tableAndJoinTable);

/**
* the table class
* <p>
* when use it the table alias will set to default like t0,t1...
* 根据class获取表,别名为表的顺序t0,t1,t2,t2
*
* @param clazz form entity class
Expand All @@ -24,6 +29,10 @@ public interface FromBuilder {
WhereBuilder from(Class<?>... clazz);

/**
* the table class with join params
* <p>
* the limit is only support join tree table,if there is complicated sql query just use the native sql
* when use it the table alias will set to default like t0,t1...
* 根据class获取表,别名为表的顺序t0,t1,t2,t2
*
* @param func join param
Expand Down
60 changes: 57 additions & 3 deletions src/main/java/com/sondertara/joya/core/builder/SelectBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,59 @@

import java.util.function.UnaryOperator;

/**
* (non-javadoc)
* the select builder
*
* @author huangxiaohu
*/
public interface SelectBuilder {

/**
* sql select part
* <p>
* example: [t0.user_name] or [t0.usr_name AS userName]
* select 要查询的列 格式为[t0.user_name] 或者[t0.usr_name AS userName]
*
* @param columns the query columns
* @return the next builder
*/
FromBuilder select(String... columns);

/**
* sql select part
* <p>
* this function will query all columns (select *),you can use {@link #specificS} together to assign alias
* <p>
* 查询表的全部列,对于联表查询 如果字段名字有重复,只保留前面一个字段,可以配置specificS来指定字段别名
*
* @return the next builder
*/
FromBuilder select();

/**
* the special query column like as alias.
* <p>
* 特殊select 字段 搭配select(),指定字段的别名
*
* @param selectFields 特殊字段
* @param selectFields the special column,usually is the column alias
* @return this builder
*/
SelectBuilder specificS(String... selectFields);

/**
* select single column
* 选择一个字段
*
* @param f1 column
* @param <T> entity
* @return query
* @return the next builder
*/
<T> FromBuilder select(TaraFunction<T, ?> f1);

/**
* select two column
*
* @param f1 column1
* @param f2 column2
* @param <T1> entity1
Expand All @@ -42,28 +66,58 @@ public interface SelectBuilder {
*/
<T1, T2> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2);


/**
* (non-javadoc)
*/
<T1, T2, T3> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6, T7> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6, TaraFunction<T7, ?> f7);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6, T7, T8> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6, TaraFunction<T7, ?> f7, TaraFunction<T8, ?> f8);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6, T7, T8, T9> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6, TaraFunction<T7, ?> f7, TaraFunction<T8, ?> f8, TaraFunction<T9, ?> f9);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6, TaraFunction<T7, ?> f7, TaraFunction<T8, ?> f8, TaraFunction<T9, ?> f9, TaraFunction<T10, ?> f10);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6, TaraFunction<T7, ?> f7, TaraFunction<T8, ?> f8, TaraFunction<T9, ?> f9, TaraFunction<T10, ?> f10, TaraFunction<T11, ?> f11);

/**
* (non-javadoc)
*/
<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> FromBuilder select(TaraFunction<T1, ?> f1, TaraFunction<T2, ?> f2, TaraFunction<T3, ?> f3, TaraFunction<T4, ?> f4, TaraFunction<T5, ?> f5, TaraFunction<T6, ?> f6, TaraFunction<T7, ?> f7, TaraFunction<T8, ?> f8, TaraFunction<T9, ?> f9, TaraFunction<T10, ?> f10, TaraFunction<T11, ?> f11, TaraFunction<T12, ?> f12);

/**
* the lambda select, use {@link #specificS(String...)} the resolve alias
* lambda select 同样冲突字段需要调用specificS()
*
* @param func select field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import com.sondertara.joya.core.query.NativeSqlQuery;

/**
* (non-javadoc)
* the start builder
*
* @author huangxiaohu
*/
public interface SetupBuilder {
/**
* builder the NativeSqlQuery
* 构造 NativeSqlQuery
*
* @return sql
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/sondertara/joya/core/builder/WhereBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
*/
public interface WhereBuilder extends ExtPartBuilder {


/**
* where
* 使用方式: nativeSql.where(w -> w.eq().ne().in())
* lambda where
* <p>
* example :nativeSql.where(w -> w.eq().ne().in())
*
* @param func the function
* @return the next builder
*/
ExtPartBuilder where(UnaryOperator<WhereCriterion> func);


/**
* where
* where part with appoint the condition link type,default is #AND
* 使用方式: nativeSql.where(w -> w.eq().ne().in())
*
* @param func 条件
* @param linkOr 是否为or查询 默认为and
* @return the next builder
*/
ExtPartBuilder where(UnaryOperator<WhereCriterion> func, boolean linkOr);

Expand All @@ -30,6 +36,7 @@ public interface WhereBuilder extends ExtPartBuilder {
* 指定字段的别名
*
* @param whereFields 特殊字段
* @return this builder
*/
WhereBuilder specificW(String... whereFields);
}

0 comments on commit 7a60cee

Please sign in to comment.