|
@@ -4,10 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
import lombok.AccessLevel;
|
|
import lombok.AccessLevel;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.example.join.domain.QueryCondition;
|
|
import org.example.join.domain.QueryCondition;
|
|
-import org.example.join.domain.Table;
|
|
|
|
-import org.example.join.domain.TableJoin;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -16,24 +13,23 @@ import java.util.Objects;
|
|
public class Join<R> {
|
|
public class Join<R> {
|
|
|
|
|
|
private final From<R> from;
|
|
private final From<R> from;
|
|
- private final Sql<R> sql;
|
|
|
|
- private final String join;
|
|
|
|
- private final Table table;
|
|
|
|
|
|
+ private final List<QueryCondition> queryConditionList;
|
|
|
|
|
|
public From<R> on(QueryCondition... queryConditions) {
|
|
public From<R> on(QueryCondition... queryConditions) {
|
|
|
|
+
|
|
if (ObjectUtil.isEmpty(queryConditions)) {
|
|
if (ObjectUtil.isEmpty(queryConditions)) {
|
|
throw new IllegalArgumentException("on不能为空");
|
|
throw new IllegalArgumentException("on不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
- List<QueryCondition> queryConditionList = new ArrayList<>(Arrays.stream(queryConditions).filter(Objects::nonNull).toList());
|
|
|
|
|
|
+ List<QueryCondition> queryConditionList = Arrays.stream(queryConditions).filter(Objects::nonNull).toList();
|
|
|
|
|
|
if (queryConditionList.isEmpty()) {
|
|
if (queryConditionList.isEmpty()) {
|
|
throw new IllegalArgumentException("on不能为空");
|
|
throw new IllegalArgumentException("on不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
- sql.queryTableList.add(new TableJoin(join, table, queryConditionList));
|
|
|
|
|
|
+ this.queryConditionList.addAll(queryConditionList);
|
|
|
|
|
|
- return from;
|
|
|
|
|
|
+ return this.from;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|