Skip to content
Merged

Dev #163

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down Expand Up @@ -346,6 +346,7 @@

<profile>
<!-- mvn clean deploy -P ossrh -->
<!-- mvn clean deploy -P ossrh -Dgpg.passphrase="你的GPG密码" -->
<!-- gpg: signing failed: Inappropriate ioctl for device -->
<!-- fix command : export GPG_TTY=$(tty) -->
<!-- https://github.com/keybase/keybase-issues/issues/2798 -->
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>

<name>springboot-starter-data-authorization</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,62 @@
class DynamicSQLBuilder {

private final PageRequest request;
private final Class<?> clazz;

private final List<Object> params = new ArrayList<>();
private int paramIndex = 1;
private final StringBuilder hql;
private final StringBuilder countHql ;

public DynamicSQLBuilder(PageRequest request, Class<?> clazz) {
this.request = request;
this.clazz = clazz;
this.hql = new StringBuilder("FROM " + clazz.getSimpleName() + " WHERE ");
this.countHql = new StringBuilder("SELECT COUNT(1) FROM " + clazz.getSimpleName() + " WHERE ");
this.build();
}

public String getHQL(){
return this.hql.toString();
}

public String getCountHQL(){
return this.countHql.toString();
}

public String getHQL() {
StringBuilder hql = new StringBuilder("FROM " + clazz.getSimpleName() + " WHERE ");
private void build() {
StringBuilder querySQL = new StringBuilder();
StringBuilder orderSQL = new StringBuilder();
RequestFilter requestFilter = request.getRequestFilter();
if (requestFilter.hasFilter()) {
List<Filter> filters = requestFilter.getFilters();
for (int i = 0; i < filters.size(); i++) {
Filter filter = filters.get(i);
this.buildSQL(filter, hql);
this.buildSQL(filter, querySQL);
if (i != filters.size() - 1) {
hql.append(" AND ");
querySQL.append(" AND ");
}
}
}

Sort sort = request.getSort();
if (sort.isSorted()) {
hql.append(" ORDER BY ");
orderSQL.append(" ORDER BY ");
List<Sort.Order> orders = sort.toList();
for (int i = 0; i < orders.size(); i++) {
Sort.Order order = orders.get(i);
hql.append(order.getProperty()).append(" ").append(order.getDirection().name());
orderSQL.append(order.getProperty()).append(" ").append(order.getDirection().name());
if (i != orders.size() - 1) {
hql.append(",");
orderSQL.append(",");
}
}
}

this.hql.append(querySQL);
this.hql.append(orderSQL);
this.countHql.append(querySQL);

log.debug("hql:{}", hql);
log.debug("params:{}", params);
return hql.toString();

}


Expand Down Expand Up @@ -171,4 +186,5 @@ private void buildSQL(Filter filter, StringBuilder hql) {
public Object[] getParams() {
return params.toArray();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ default Page<T> pageRequest(PageRequest request) {
if (request.hasFilter()) {
Class<T> clazz = getEntityClass();
DynamicSQLBuilder dynamicSQLBuilder = new DynamicSQLBuilder(request, clazz);
return dynamicPageQuery(dynamicSQLBuilder.getHQL(), request, dynamicSQLBuilder.getParams());
return dynamicPageQuery(dynamicSQLBuilder.getHQL(), dynamicSQLBuilder.getCountHQL(),request, dynamicSQLBuilder.getParams());
}
return findAll((org.springframework.data.domain.PageRequest) request);
}
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>

<artifactId>springboot-starter-security</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.21</version>
<version>3.4.22</version>
</parent>
<artifactId>springboot-starter</artifactId>

Expand Down