Skip to content

Commit

Permalink
v3.0.7 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
scx567888 authored Sep 3, 2024
1 parent d17de74 commit 6fa1d59
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 126 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>scx</artifactId>
<packaging>pom</packaging>
<version>3.0.6</version>
<version>3.0.7</version>

<name>SCX</name>
<url>https://github.com/scx567888/scx</url>
Expand Down
2 changes: 1 addition & 1 deletion scx-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-config</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-core/src/main/java/cool/scx/core/ScxVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ScxVersion {
/**
* SCX 版本号
*/
public static final String SCX_VERSION = "3.0.6";
public static final String SCX_VERSION = "3.0.7";

/**
* 在控制台上打印 banner
Expand Down
2 changes: 1 addition & 1 deletion scx-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-data-jdbc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-data-mysql-x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-data-mysql-x</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-data</artifactId>
Expand Down
15 changes: 8 additions & 7 deletions scx-data/src/main/java/cool/scx/data/query/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

import static cool.scx.data.query.WhereType.*;

Expand All @@ -26,19 +25,21 @@ public Object[] clauses() {

public Logic add(Object... logicCauses) {
for (var logicCause : logicCauses) {
if (logicCause == null) {
continue;
}
if (logicCause instanceof Object[] objs) {
add(objs);
continue;
}
if (logicCause instanceof Where w && w.info().replace()) {
removeIf(c -> c instanceof Where w1 && w1.name().equals(w.name()));
clauses.removeIf(c -> c instanceof Where w1 && w1.name().equals(w.name()));
}
clauses.add(logicCause);
}
return this;
}

public Logic removeIf(Predicate<Object> filter) {
clauses.removeIf(filter);
return this;
}

public Logic clear() {
clauses.clear();
return this;
Expand Down
14 changes: 0 additions & 14 deletions scx-data/src/main/java/cool/scx/data/query/Query.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cool.scx.data.query;

import java.util.function.Predicate;

public interface Query {

Query where(Object... whereClauses);
Expand All @@ -14,18 +12,6 @@ public interface Query {

Query limit(long numberOfRows);

Query addWhere(Object... whereClauses);

Query addGroupBy(Object... groupByClauses);

Query addOrderBy(Object... orderByClauses);

Query removeWhereIf(Predicate<Object> filter);

Query removeGroupByIf(Predicate<Object> filter);

Query removeOrderByIf(Predicate<Object> filter);

Object[] getWhere();

Object[] getGroupBy();
Expand Down
103 changes: 51 additions & 52 deletions scx-data/src/main/java/cool/scx/data/query/QueryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
* 默认实现
Expand Down Expand Up @@ -78,57 +77,6 @@ public QueryImpl limit(long limit) {
return this;
}

@Override
public QueryImpl addWhere(Object... whereClauses) {
for (var whereClause : whereClauses) {
if (whereClause instanceof Where w && w.info().replace()) {
removeWhereIf(c -> c instanceof Where w1 && w1.name().equals(w.name()));
}
where.add(whereClause);
}
return this;
}

@Override
public QueryImpl addGroupBy(Object... groupByClauses) {
for (var groupByClause : groupByClauses) {
if (groupByClause instanceof GroupBy w && w.info().replace()) {
removeGroupByIf(c -> c instanceof GroupBy w1 && w1.name().equals(w.name()));
}
groupBy.add(groupByClause);
}
return this;
}

@Override
public QueryImpl addOrderBy(Object... orderByClauses) {
for (var orderByClause : orderByClauses) {
if (orderByClause instanceof OrderBy w && w.info().replace()) {
removeOrderByIf(c -> c instanceof OrderBy w1 && w1.name().equals(w.name()));
}
orderBy.add(orderByClause);
}
return this;
}

@Override
public Query removeWhereIf(Predicate<Object> filter) {
where.removeIf(filter);
return this;
}

@Override
public Query removeGroupByIf(Predicate<Object> filter) {
groupBy.removeIf(filter);
return this;
}

@Override
public Query removeOrderByIf(Predicate<Object> filter) {
orderBy.removeIf(filter);
return this;
}

@Override
public Object[] getWhere() {
return where.toArray();
Expand Down Expand Up @@ -184,4 +132,55 @@ public QueryImpl clearLimit() {
return this;
}

private QueryImpl addWhere(Object... whereClauses) {
for (var whereClause : whereClauses) {
if (whereClause == null) {
continue;
}
if (whereClause instanceof Object[] objs) {
addWhere(objs);
continue;
}
if (whereClause instanceof Where w && w.info().replace()) {
where.removeIf(c -> c instanceof Where w1 && w1.name().equals(w.name()));
}
where.add(whereClause);
}
return this;
}

private QueryImpl addGroupBy(Object... groupByClauses) {
for (var groupByClause : groupByClauses) {
if (groupByClause == null) {
continue;
}
if (groupByClause instanceof Object[] objs) {
addGroupBy(objs);
continue;
}
if (groupByClause instanceof GroupBy w && w.info().replace()) {
groupBy.removeIf(c -> c instanceof GroupBy w1 && w1.name().equals(w.name()));
}
groupBy.add(groupByClause);
}
return this;
}

private QueryImpl addOrderBy(Object... orderByClauses) {
for (var orderByClause : orderByClauses) {
if (orderByClause == null) {
continue;
}
if (orderByClause instanceof Object[] objs) {
addOrderBy(objs);
continue;
}
if (orderByClause instanceof OrderBy w && w.info().replace()) {
orderBy.removeIf(c -> c instanceof OrderBy w1 && w1.name().equals(w.name()));
}
orderBy.add(orderByClause);
}
return this;
}

}
38 changes: 0 additions & 38 deletions scx-data/src/main/java/cool/scx/data/query/QueryLike.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cool.scx.data.query;

import java.util.function.Predicate;

@SuppressWarnings("unchecked")
public abstract class QueryLike<QL extends QueryLike<QL>> implements Query {

Expand Down Expand Up @@ -44,42 +42,6 @@ public QL limit(long numberOfRows) {
return (QL) this;
}

@Override
public QL addWhere(Object... whereClauses) {
query().addWhere(whereClauses);
return (QL) this;
}

@Override
public QL addGroupBy(Object... groupByClauses) {
query().addGroupBy(groupByClauses);
return (QL) this;
}

@Override
public QL addOrderBy(Object... orderByClauses) {
query().addOrderBy(orderByClauses);
return (QL) this;
}

@Override
public QL removeWhereIf(Predicate<Object> filter) {
query().removeWhereIf(filter);
return (QL) this;
}

@Override
public QL removeGroupByIf(Predicate<Object> filter) {
query().removeGroupByIf(filter);
return (QL) this;
}

@Override
public QL removeOrderByIf(Predicate<Object> filter) {
query().removeOrderByIf(filter);
return (QL) this;
}

@Override
public Object[] getWhere() {
return query().getWhere();
Expand Down
2 changes: 1 addition & 1 deletion scx-ext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-ext</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-jdbc-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-jdbc-mysql</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-jdbc-sqlite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-jdbc-sqlite</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-jdbc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-logging</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-socket/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-socket</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion scx-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cool.scx</groupId>
<artifactId>scx</artifactId>
<version>3.0.6</version>
<version>3.0.7</version>
</parent>

<artifactId>scx-web</artifactId>
Expand Down

0 comments on commit 6fa1d59

Please sign in to comment.