From 09e8037ff18be339cca8714a9dffee210abdd1f5 Mon Sep 17 00:00:00 2001 From: yulichang <570810310@qq.com> Date: Fri, 16 Dec 2022 17:02:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=20geSql=20gtSql=20leSql=20lt?= =?UTF-8?q?Sql=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wrapper/MPJAbstractLambdaWrapper.java | 18 +- .../yulichang/wrapper/MPJAbstractWrapper.java | 307 ++++++++++++- .../yulichang/wrapper/MPJLambdaWrapper.java | 8 +- .../wrapper/interfaces/CompareStr.java | 284 ++++++++++++ .../yulichang/wrapper/interfaces/Func.java | 79 +++- .../yulichang/wrapper/interfaces/FuncStr.java | 408 ++++++++++++++++++ .../yulichang/wrapper/interfaces/Query.java | 11 + .../wrapper/interfaces/QueryJoin.java | 44 +- .../wrapper/interfaces/WrapperBiConsumer.java | 9 - .../wrapper/interfaces/WrapperFunction.java | 4 +- .../yulichang/wrapper/segments/Select.java | 2 + .../wrapper/segments/SelectAlias.java | 5 + .../wrapper/segments/SelectFunc.java | 5 + .../wrapper/segments/SelectLabel.java | 5 + .../wrapper/segments/SelectNormal.java | 5 + .../wrapper/segments/SelectString.java | 99 +++++ 16 files changed, 1233 insertions(+), 60 deletions(-) create mode 100644 mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/CompareStr.java create mode 100644 mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java delete mode 100644 mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperBiConsumer.java create mode 100644 mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectString.java diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java index c050c7d..f4c374f 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java @@ -32,19 +32,19 @@ public abstract class MPJAbstractLambdaWrapper String columnToString(String index, int node, X column, boolean isJoin) { - return columnToString(index, node, (SFunction) column, isJoin); + protected String columnToString(String index, int node, X column, boolean isJoin, Class parent) { + return columnToString(index, node, (SFunction) column, isJoin, parent); } @Override @SafeVarargs - protected final String columnsToString(String index, int node, boolean isJoin, X... columns) { - return Arrays.stream(columns).map(i -> columnToString(index, node, (SFunction) i, isJoin)).collect(joining(StringPool.COMMA)); + protected final String columnsToString(String index, int node, boolean isJoin, Class parent, X... columns) { + return Arrays.stream(columns).map(i -> columnToString(index, node, (SFunction) i, isJoin, parent)).collect(joining(StringPool.COMMA)); } - protected String columnToString(String index, int node, SFunction column, boolean isJoin) { + protected String columnToString(String index, int node, SFunction column, boolean isJoin, Class parent) { Class entityClass = LambdaUtils.getEntityClass(column); - return Constant.TABLE_ALIAS + getDefault(index, node, entityClass, isJoin) + StringPool.DOT + + return Constant.TABLE_ALIAS + getDefault(index, node, entityClass, isJoin, parent) + StringPool.DOT + getCache(column).getTagColumn(); } @@ -54,7 +54,7 @@ public abstract class MPJAbstractLambdaWrapper clazz, boolean isJoin) { + protected String getDefault(String index, int node, Class clazz, boolean isJoin, Class parent) { if (Objects.isNull(index)) { if (!isJoin && Objects.equals(clazz, getEntityClass())) { return StringPool.EMPTY; @@ -65,7 +65,7 @@ public abstract class MPJAbstractLambdaWrapper> extends Wrapper - implements Compare, Nested, Join, Func, OnCompare { + implements Compare, Nested, Join, Func, OnCompare, + CompareStr, FuncStr { protected static final Node ROOT_NODE = new Node(null, 0, null); @@ -323,11 +320,36 @@ public abstract class MPJAbstractWrapper String.format("(%s)", inValue))); } + + @Override + public Children gtSql(boolean condition, SFunction column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), GT, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children geSql(boolean condition, SFunction column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), GE, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children ltSql(boolean condition, SFunction column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), LT, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children leSql(boolean condition, SFunction column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), LE, + () -> String.format("(%s)", inValue))); + } + @Override public Children groupBy(boolean condition, List> columns) { return maybeDo(condition, () -> { if (CollectionUtils.isNotEmpty(columns)) { - String one = (StringPool.COMMA + columnsToString(index, getByClass(node, joinClass), false, columns)); + String one = (StringPool.COMMA + columnsToString(index, getByClass(node, joinClass), false, parentClass(node), columns)); final String finalOne = one; appendSqlSegments(GROUP_BY, () -> finalOne); } @@ -337,9 +359,9 @@ public abstract class MPJAbstractWrapper Children groupBy(boolean condition, SFunction column, SFunction... columns) { return maybeDo(condition, () -> { - String one = columnToString(index, getByClass(node, joinClass), column, false); + String one = columnToString(index, getByClass(node, joinClass), column, false, parentClass(node)); if (ArrayUtils.isNotEmpty(columns)) { - one += (StringPool.COMMA + columnsToString(index, getByClass(node, joinClass), false, columns)); + one += (StringPool.COMMA + columnsToString(index, getByClass(node, joinClass), false, parentClass(node), columns)); } final String finalOne = one; appendSqlSegments(GROUP_BY, () -> finalOne); @@ -426,6 +448,11 @@ public abstract class MPJAbstractWrapper formatParam(null, SqlUtils.concatLike(val, sqlLike)))); } + protected Children likeValue(boolean condition, SqlKeyword keyword, String column, Object val, SqlLike sqlLike) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), keyword, + () -> formatParam(null, SqlUtils.concatLike(val, sqlLike)))); + } + /** * 普通查询条件 * @@ -440,11 +467,15 @@ public abstract class MPJAbstractWrapper Children addCondition(boolean condition, SFunction column, SqlKeyword sqlKeyword, SFunction val) { - Node nnnn = this.node; return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), sqlKeyword, columnToSqlSegment(index, val, true))); } + protected Children addCondition(boolean condition, String column, SqlKeyword sqlKeyword, Object val) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), sqlKeyword, + () -> formatParam(null, val))); + } + /** * 多重嵌套查询条件 * @@ -626,23 +657,40 @@ public abstract class MPJAbstractWrapper ISqlSegment columnToSqlSegment(String index, SFunction column, boolean isJoin) { - return () -> columnToString(index, getByClass(node, joinClass), column, isJoin); + return () -> columnToString(index, getByClass(node, joinClass), column, isJoin, parentClass(node)); + } + + protected final ISqlSegment columnToSqlSegment(String column) { + return () -> (String) column; } /** * 获取 columnName */ - protected String columnToString(String index, int node, X column, boolean isJoin) { + protected String columnToString(String index, int node, X column, boolean isJoin, Class parent) { return (String) column; } + protected String columnToString(String column) { + return column; + } + + protected String columnsToString(List columns) { + return columns.stream().map(this::columnToString).collect(joining(StringPool.COMMA)); + } + + protected String columnsToString(String... columns) { + return Arrays.stream(columns).map(this::columnToString).collect(joining(StringPool.COMMA)); + } + + /** * 多字段转换为逗号 "," 分割字符串 * * @param columns 多字段 */ - protected String columnsToString(String index, int node, boolean isJoin, X... columns) { - return Arrays.stream(columns).map(i -> this.columnToString(index, node, i, isJoin)).collect(joining(StringPool.COMMA)); + protected String columnsToString(String index, int node, boolean isJoin, Class parent, X... columns) { + return Arrays.stream(columns).map(i -> this.columnToString(index, node, i, isJoin, parent)).collect(joining(StringPool.COMMA)); } @Override @@ -692,8 +740,7 @@ public abstract class MPJAbstractWrapper parentClass(Node node) { + if (node == null || node.parent == null) { + return null; + } + return node.parent.clazz; + } + private int dg(Node node, Class joinClass) { if (node.clazz != null && node.clazz == joinClass) { @@ -725,4 +779,225 @@ public abstract class MPJAbstractWrapper Children allEqStr(boolean condition, Map params, boolean null2IsNull) { + if (condition && CollectionUtils.isNotEmpty(params)) { + params.forEach((k, v) -> { + if (StringUtils.checkValNotNull(v)) { + eq(k, v); + } else { + if (null2IsNull) { + isNull(k); + } + } + }); + } + return typedThis; + } + + @Override + public Children allEqStr(boolean condition, BiPredicate filter, Map params, boolean null2IsNull) { + if (condition && CollectionUtils.isNotEmpty(params)) { + params.forEach((k, v) -> { + if (filter.test(k, v)) { + if (StringUtils.checkValNotNull(v)) { + eq(k, v); + } else { + if (null2IsNull) { + isNull(k); + } + } + } + }); + } + return typedThis; + } + + @Override + public Children eq(boolean condition, String column, Object val) { + return addCondition(condition, column, EQ, val); + } + + @Override + public Children ne(boolean condition, String column, Object val) { + return addCondition(condition, column, NE, val); + } + + @Override + public Children gt(boolean condition, String column, Object val) { + return addCondition(condition, column, GT, val); + } + + @Override + public Children ge(boolean condition, String column, Object val) { + return addCondition(condition, column, GE, val); + } + + @Override + public Children lt(boolean condition, String column, Object val) { + return addCondition(condition, column, LT, val); + } + + @Override + public Children le(boolean condition, String column, Object val) { + return addCondition(condition, column, LE, val); + } + + @Override + public Children like(boolean condition, String column, Object val) { + return likeValue(condition, LIKE, column, val, SqlLike.DEFAULT); + } + + @Override + public Children notLike(boolean condition, String column, Object val) { + return likeValue(condition, NOT_LIKE, column, val, SqlLike.DEFAULT); + } + + @Override + public Children likeLeft(boolean condition, String column, Object val) { + return likeValue(condition, LIKE, column, val, SqlLike.LEFT); + } + + @Override + public Children likeRight(boolean condition, String column, Object val) { + return likeValue(condition, LIKE, column, val, SqlLike.RIGHT); + } + + @Override + public Children between(boolean condition, String column, Object val1, Object val2) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), BETWEEN, + () -> formatParam(null, val1), AND, () -> formatParam(null, val2))); + } + + @Override + public Children notBetween(boolean condition, String column, Object val1, Object val2) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), NOT_BETWEEN, + () -> formatParam(null, val1), AND, () -> formatParam(null, val2))); + } + + + /* ****************************************** **/ + + + @Override + public Children isNull(boolean condition, String column) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), IS_NULL)); + } + + @Override + public Children isNotNull(boolean condition, String column) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), IS_NOT_NULL)); + } + + @Override + public Children in(boolean condition, String column, Collection coll) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), IN, inExpression(coll))); + } + + @Override + public Children in(boolean condition, String column, Object... values) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), IN, inExpression(values))); + } + + @Override + public Children notIn(boolean condition, String column, Collection coll) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), NOT_IN, inExpression(coll))); + } + + @Override + public Children notIn(boolean condition, String column, Object... values) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), NOT_IN, inExpression(values))); + } + + @Override + public Children inSql(boolean condition, String column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), IN, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children gtSql(boolean condition, String column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), GT, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children geSql(boolean condition, String column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), GE, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children ltSql(boolean condition, String column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), LT, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children leSql(boolean condition, String column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), LE, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children notInSql(boolean condition, String column, String inValue) { + return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(column), NOT_IN, + () -> String.format("(%s)", inValue))); + } + + @Override + public Children groupBy(boolean condition, String column, String... columns) { + return maybeDo(condition, () -> { + String one = columnToString(column); + if (ArrayUtils.isNotEmpty(columns)) { + one += (StringPool.COMMA + columnsToString(columns)); + } + final String finalOne = one; + appendSqlSegments(GROUP_BY, () -> finalOne); + }); + } + + @Override + public final Children orderBy(boolean condition, boolean isAsc, String column, String... columns) { + return maybeDo(condition, () -> { + final SqlKeyword mode = isAsc ? ASC : DESC; + appendSqlSegments(ORDER_BY, columnToSqlSegment(columnSqlInjectFilter(column)), mode); + if (ArrayUtils.isNotEmpty(columns)) { + Arrays.stream(columns).forEach(c -> appendSqlSegments(ORDER_BY, + columnToSqlSegment(columnSqlInjectFilter(c)), mode)); + } + }); + } + + protected String columnSqlInjectFilter(String column) { + return StringUtils.sqlInjectionReplaceBlank(column); + } + + @Override + public Children groupBy(boolean condition, String column) { + return maybeDo(condition, () -> appendSqlSegments(GROUP_BY, () -> columnToString(column))); + } + + @Override + public Children groupByStr(boolean condition, List columns) { + return maybeDo(condition, () -> appendSqlSegments(GROUP_BY, () -> columnsToString(columns))); + } + + @Override + public Children orderBy(boolean condition, boolean isAsc, String column) { + return maybeDo(condition, () -> appendSqlSegments(ORDER_BY, columnToSqlSegment(columnSqlInjectFilter(column)), + isAsc ? ASC : DESC)); + } + + @Override + public Children orderByStr(boolean condition, boolean isAsc, List columns) { + return maybeDo(condition, () -> columns.forEach(c -> appendSqlSegments(ORDER_BY, + columnToSqlSegment(columnSqlInjectFilter(c)), isAsc ? ASC : DESC))); + } + + } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJLambdaWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJLambdaWrapper.java index 6e203a0..39b3e17 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJLambdaWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJLambdaWrapper.java @@ -17,7 +17,6 @@ import com.github.yulichang.toolkit.support.ColumnCache; import com.github.yulichang.wrapper.interfaces.Query; import com.github.yulichang.wrapper.interfaces.QueryJoin; import com.github.yulichang.wrapper.interfaces.QueryLabel; -import com.github.yulichang.wrapper.interfaces.WrapperBiConsumer; import com.github.yulichang.wrapper.resultmap.MybatisLabel; import com.github.yulichang.wrapper.segments.Select; import com.github.yulichang.wrapper.segments.SelectCache; @@ -29,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BiConsumer; import java.util.stream.Collectors; /** @@ -184,6 +184,9 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper { + if (i.isStr()) { + return i.getColumn(); + } String str = Constant.TABLE_ALIAS + getDefaultSelect(i.getIndex(), i.getClazz(), i) + StringPool.DOT + i.getColumn(); return i.isFunc() ? (String.format(i.getFunc().getSql(), str) + Constant.AS + i.getAlias()) : (i.isHasAlias() ? (str + Constant.AS + i.getAlias()) : str); }).collect(Collectors.joining(StringPool.COMMA)); @@ -302,8 +305,7 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper MPJLambdaWrapper join(String keyWord, Class clazz, WrapperBiConsumer consumer) { - Node nnnnn = this.node; + public MPJLambdaWrapper join(String keyWord, Class clazz, BiConsumer, MPJLambdaWrapper> consumer) { String oldIndex = this.getIndex(); String newIndex = String.valueOf(tableIndex); Node n = Objects.isNull(oldIndex) ? new Node(clazz, tableIndex, ROOT_NODE) : new Node(clazz, tableIndex, this.node); diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/CompareStr.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/CompareStr.java new file mode 100644 index 0000000..c70f917 --- /dev/null +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/CompareStr.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2011-2022, baomidou (jobob@qq.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.yulichang.wrapper.interfaces; + +import java.io.Serializable; +import java.util.Map; +import java.util.function.BiPredicate; + +/** + * copu {@link com.baomidou.mybatisplus.core.conditions.interfaces.Compare} + * + * @since 1.3.12 + */ +@SuppressWarnings("ALL") +public interface CompareStr extends Serializable { + + /** + * ignore + */ + default Children allEqStr(Map params) { + return allEqStr(params, true); + } + + /** + * ignore + */ + default Children allEqStr(Map params, boolean null2IsNull) { + return allEqStr(true, params, null2IsNull); + } + + /** + * map 所有非空属性等于 = + * + * @param condition 执行条件 + * @param params map 类型的参数, key 是字段名, value 是字段值 + * @param null2IsNull 是否参数为 null 自动执行 isNull 方法, false 则忽略这个字段\ + * @return children + */ + Children allEqStr(boolean condition, Map params, boolean null2IsNull); + + /** + * ignore + */ + default Children allEqStr(BiPredicate filter, Map params) { + return allEqStr(filter, params, true); + } + + /** + * ignore + */ + default Children allEqStr(BiPredicate filter, Map params, boolean null2IsNull) { + return allEqStr(true, filter, params, null2IsNull); + } + + /** + * 字段过滤接口,传入多参数时允许对参数进行过滤 + * + * @param condition 执行条件 + * @param filter 返回 true 来允许字段传入比对条件中 + * @param params map 类型的参数, key 是字段名, value 是字段值 + * @param null2IsNull 是否参数为 null 自动执行 isNull 方法, false 则忽略这个字段 + * @return children + */ + Children allEqStr(boolean condition, BiPredicate filter, Map params, boolean null2IsNull); + + /** + * ignore + */ + default Children eq(R column, Object val) { + return eq(true, column, val); + } + + /** + * 等于 = + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children eq(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children ne(R column, Object val) { + return ne(true, column, val); + } + + /** + * 不等于 <> + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children ne(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children gt(R column, Object val) { + return gt(true, column, val); + } + + /** + * 大于 > + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children gt(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children ge(R column, Object val) { + return ge(true, column, val); + } + + /** + * 大于等于 >= + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children ge(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children lt(R column, Object val) { + return lt(true, column, val); + } + + /** + * 小于 < + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children lt(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children le(R column, Object val) { + return le(true, column, val); + } + + /** + * 小于等于 <= + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children le(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children between(R column, Object val1, Object val2) { + return between(true, column, val1, val2); + } + + /** + * BETWEEN 值1 AND 值2 + * + * @param condition 执行条件 + * @param column 字段 + * @param val1 值1 + * @param val2 值2 + * @return children + */ + Children between(boolean condition, R column, Object val1, Object val2); + + /** + * ignore + */ + default Children notBetween(R column, Object val1, Object val2) { + return notBetween(true, column, val1, val2); + } + + /** + * NOT BETWEEN 值1 AND 值2 + * + * @param condition 执行条件 + * @param column 字段 + * @param val1 值1 + * @param val2 值2 + * @return children + */ + Children notBetween(boolean condition, R column, Object val1, Object val2); + + /** + * ignore + */ + default Children like(R column, Object val) { + return like(true, column, val); + } + + /** + * LIKE '%值%' + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children like(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children notLike(R column, Object val) { + return notLike(true, column, val); + } + + /** + * NOT LIKE '%值%' + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children notLike(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children likeLeft(R column, Object val) { + return likeLeft(true, column, val); + } + + /** + * LIKE '%值' + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children likeLeft(boolean condition, R column, Object val); + + /** + * ignore + */ + default Children likeRight(R column, Object val) { + return likeRight(true, column, val); + } + + /** + * LIKE '值%' + * + * @param condition 执行条件 + * @param column 字段 + * @param val 值 + * @return children + */ + Children likeRight(boolean condition, R column, Object val); +} diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Func.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Func.java index abbecba..a167f2b 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Func.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Func.java @@ -12,7 +12,7 @@ import java.util.function.Consumer; *

* copy {@link com.baomidou.mybatisplus.core.conditions.interfaces.Func} */ -@SuppressWarnings({"unchecked", "unused"}) +@SuppressWarnings({"unchecked", "unused", "JavadocDeclaration"}) public interface Func extends Serializable { /** @@ -168,6 +168,83 @@ public interface Func extends Serializable { */ Children notInSql(boolean condition, SFunction column, String inValue); + + /** + * 字段 > ( sql语句 ) + *

例1: gtSql("id", "1, 2, 3, 4, 5, 6")

+ *

例1: gtSql("id", "select id from table where name = 'JunJun'")

+ * + * @param condition + * @param column + * @param inValue + * @return + */ + Children gtSql(boolean condition, SFunction column, String inValue); + + /** + * ignore + */ + default Children gtSql(SFunction column, String inValue) { + return gtSql(true, column, inValue); + } + + /** + * 字段 >= ( sql语句 ) + *

例1: geSql("id", "1, 2, 3, 4, 5, 6")

+ *

例1: geSql("id", "select id from table where name = 'JunJun'")

+ * + * @param condition + * @param column + * @param inValue + * @return + */ + Children geSql(boolean condition, SFunction column, String inValue); + + /** + * ignore + */ + default Children geSql(SFunction column, String inValue) { + return geSql(true, column, inValue); + } + + /** + * 字段 < ( sql语句 ) + *

例1: ltSql("id", "1, 2, 3, 4, 5, 6")

+ *

例1: ltSql("id", "select id from table where name = 'JunJun'")

+ * + * @param condition + * @param column + * @param inValue + * @return + */ + Children ltSql(boolean condition, SFunction column, String inValue); + + /** + * ignore + */ + default Children ltSql(SFunction column, String inValue) { + return ltSql(true, column, inValue); + } + + /** + * 字段 <= ( sql语句 ) + *

例1: leSql("id", "1, 2, 3, 4, 5, 6")

+ *

例1: leSql("id", "select id from table where name = 'JunJun'")

+ * + * @param condition + * @param column + * @param inValue + * @return + */ + Children leSql(boolean condition, SFunction column, String inValue); + + /** + * ignore + */ + default Children leSql(SFunction column, String inValue) { + return leSql(true, column, inValue); + } + /** * ignore */ diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java new file mode 100644 index 0000000..570636a --- /dev/null +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2011-2022, baomidou (jobob@qq.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.github.yulichang.wrapper.interfaces; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +/** + * copy {@link com.baomidou.mybatisplus.core.conditions.interfaces.Func} + * + * @since 1.3.12 + */ +@SuppressWarnings("ALL") +public interface FuncStr extends Serializable { + + /** + * ignore + */ + default Children isNull(R column) { + return isNull(true, column); + } + + /** + * 字段 IS NULL + *

例: isNull("name")

+ * + * @param condition 执行条件 + * @param column 字段 + * @return children + */ + Children isNull(boolean condition, R column); + + /** + * ignore + */ + default Children isNotNull(R column) { + return isNotNull(true, column); + } + + /** + * 字段 IS NOT NULL + *

例: isNotNull("name")

+ * + * @param condition 执行条件 + * @param column 字段 + * @return children + */ + Children isNotNull(boolean condition, R column); + + /** + * ignore + */ + default Children in(R column, Collection coll) { + return in(true, column, coll); + } + + /** + * 字段 IN (value.get(0), value.get(1), ...) + *

例: in("id", Arrays.asList(1, 2, 3, 4, 5))

+ * + *
  • 注意!集合为空若存在逻辑错误,请在 condition 条件中判断
  • + *
  • 如果集合为 empty 则不会进行 sql 拼接
  • + * + * @param condition 执行条件 + * @param column 字段 + * @param coll 数据集合 + * @return children + */ + Children in(boolean condition, R column, Collection coll); + + /** + * ignore + */ + default Children in(R column, Object... values) { + return in(true, column, values); + } + + /** + * 字段 IN (v0, v1, ...) + *

    例: in("id", 1, 2, 3, 4, 5)

    + * + *
  • 注意!数组为空若存在逻辑错误,请在 condition 条件中判断
  • + *
  • 如果动态数组为 empty 则不会进行 sql 拼接
  • + * + * @param condition 执行条件 + * @param column 字段 + * @param values 数据数组 + * @return children + */ + Children in(boolean condition, R column, Object... values); + + /** + * ignore + */ + default Children notIn(R column, Collection coll) { + return notIn(true, column, coll); + } + + /** + * 字段 NOT IN (value.get(0), value.get(1), ...) + *

    例: notIn("id", Arrays.asList(1, 2, 3, 4, 5))

    + * + * @param condition 执行条件 + * @param column 字段 + * @param coll 数据集合 + * @return children + */ + Children notIn(boolean condition, R column, Collection coll); + + /** + * ignore + */ + default Children notIn(R column, Object... value) { + return notIn(true, column, value); + } + + /** + * 字段 NOT IN (v0, v1, ...) + *

    例: notIn("id", 1, 2, 3, 4, 5)

    + * + * @param condition 执行条件 + * @param column 字段 + * @param values 数据数组 + * @return children + */ + Children notIn(boolean condition, R column, Object... values); + + /** + * ignore + */ + default Children inSql(R column, String inValue) { + return inSql(true, column, inValue); + } + + /** + * 字段 IN ( sql语句 ) + *

    !! sql 注入方式的 in 方法 !!

    + *

    例1: inSql("id", "1, 2, 3, 4, 5, 6")

    + *

    例2: inSql("id", "select id from table where id < 3")

    + * + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 + * @return children + */ + Children inSql(boolean condition, R column, String inValue); + + /** + * 字段 > ( sql语句 ) + *

    例1: gtSql("id", "1, 2, 3, 4, 5, 6")

    + *

    例1: gtSql("id", "select id from table where name = 'JunJun'")

    + * + * @param condition + * @param column + * @param inValue + * @return + */ + Children gtSql(boolean condition, R column, String inValue); + + /** + * ignore + */ + default Children gtSql(R column, String inValue) { + return gtSql(true, column, inValue); + } + + /** + * 字段 >= ( sql语句 ) + *

    例1: geSql("id", "1, 2, 3, 4, 5, 6")

    + *

    例1: geSql("id", "select id from table where name = 'JunJun'")

    + * + * @param condition + * @param column + * @param inValue + * @return + */ + Children geSql(boolean condition, R column, String inValue); + + /** + * ignore + */ + default Children geSql(R column, String inValue) { + return geSql(true, column, inValue); + } + + /** + * 字段 < ( sql语句 ) + *

    例1: ltSql("id", "1, 2, 3, 4, 5, 6")

    + *

    例1: ltSql("id", "select id from table where name = 'JunJun'")

    + * + * @param condition + * @param column + * @param inValue + * @return + */ + Children ltSql(boolean condition, R column, String inValue); + + /** + * ignore + */ + default Children ltSql(R column, String inValue) { + return ltSql(true, column, inValue); + } + + /** + * 字段 <= ( sql语句 ) + *

    例1: leSql("id", "1, 2, 3, 4, 5, 6")

    + *

    例1: leSql("id", "select id from table where name = 'JunJun'")

    + * + * @param condition + * @param column + * @param inValue + * @return + */ + Children leSql(boolean condition, R column, String inValue); + + /** + * ignore + */ + default Children leSql(R column, String inValue) { + return leSql(true, column, inValue); + } + + /** + * ignore + */ + default Children notInSql(R column, String inValue) { + return notInSql(true, column, inValue); + } + + /** + * 字段 NOT IN ( sql语句 ) + *

    !! sql 注入方式的 not in 方法 !!

    + *

    例1: notInSql("id", "1, 2, 3, 4, 5, 6")

    + *

    例2: notInSql("id", "select id from table where id < 3")

    + * + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 ---> 1,2,3,4,5,6 或者 select id from table where id < 3 + * @return children + */ + Children notInSql(boolean condition, R column, String inValue); + + /** + * 分组:GROUP BY 字段, ... + *

    例: groupBy("id")

    + * + * @param condition 执行条件 + * @param column 单个字段 + * @return children + */ + Children groupBy(boolean condition, R column); + + default Children groupBy(R column) { + return groupBy(true, column); + } + + /** + * 分组:GROUP BY 字段, ... + *

    例: groupBy(Arrays.asList("id", "name"))

    + * + * @param condition 执行条件 + * @param columns 字段数组 + * @return children + */ + Children groupByStr(boolean condition, List columns); + + default Children groupByStr(List columns) { + return groupByStr(true, columns); + } + + default Children groupBy(R column, R... columns) { + return groupBy(true, column, columns); + } + + /** + * 分组:GROUP BY 字段, ... + */ + Children groupBy(boolean condition, R column, R... columns); + + /** + * 排序:ORDER BY 字段, ... ASC + *

    例: orderByAsc(true, "id")

    + * + * @param condition 执行条件 + * @param column 单个字段 + * @return children + */ + default Children orderByAsc(boolean condition, R column) { + return orderBy(condition, true, column); + } + + default Children orderByAsc(R column) { + return orderByAsc(true, column); + } + + /** + * 排序:ORDER BY 字段, ... ASC + *

    例: orderByAsc(true, Arrays.asList("id", "name"))

    + * + * @param condition 执行条件 + * @param columns 字段数组 + * @return children + */ + default Children orderByAscStr(boolean condition, List columns) { + return orderByStr(condition, true, columns); + } + + default Children orderByAscStr(List columns) { + return orderByAscStr(true, columns); + } + + default Children orderByAsc(R column, R... columns) { + return orderByAsc(true, column, columns); + } + + /** + * 排序:ORDER BY 字段, ... ASC + */ + default Children orderByAsc(boolean condition, R column, R... columns) { + return orderBy(condition, true, column, columns); + } + + /** + * 排序:ORDER BY 字段, ... DESC + *

    例: orderByDesc(true, "id")

    + * + * @param condition 执行条件 + * @param column 字段 + * @return children + */ + default Children orderByDesc(boolean condition, R column) { + return orderBy(condition, false, column); + } + + default Children orderByDesc(R column) { + return orderByDesc(true, column); + } + + /** + * 排序:ORDER BY 字段, ... DESC + *

    例: orderByDesc(true, Arrays.asList("id", "name"))

    + * + * @param condition 执行条件 + * @param columns 字段列表 + * @return children + */ + default Children orderByDescStr(boolean condition, List columns) { + return orderByStr(condition, false, columns); + } + + default Children orderByDescStr(List columns) { + return orderByDescStr(true, columns); + } + + default Children orderByDesc(R column, R... columns) { + return orderByDesc(true, column, columns); + } + + /** + * 排序:ORDER BY 字段, ... DESC + */ + default Children orderByDesc(boolean condition, R column, R... columns) { + return orderBy(condition, false, column, columns); + } + + /** + * 排序:ORDER BY 字段, ... + *

    例: orderBy(true, "id")

    + * + * @param condition 执行条件 + * @param isAsc 是否是 ASC 排序 + * @param column 单个字段 + * @return children + */ + Children orderBy(boolean condition, boolean isAsc, R column); + + /** + * 排序:ORDER BY 字段, ... + *

    例: orderBy(true, Arrays.asList("id", "name"))

    + * + * @param condition 执行条件 + * @param isAsc 是否是 ASC 排序 + * @param columns 字段列表 + * @return children + */ + Children orderByStr(boolean condition, boolean isAsc, List columns); + + /** + * 排序:ORDER BY 字段, ... + */ + Children orderBy(boolean condition, boolean isAsc, R column, R... columns); + +} diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java index 5c82594..2053654 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java @@ -13,6 +13,7 @@ import com.github.yulichang.wrapper.segments.*; import java.io.Serializable; import java.lang.reflect.Field; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.function.Predicate; @@ -57,6 +58,16 @@ public interface Query extends Serializable { @SuppressWarnings("unchecked") Children select(SFunction... columns); + /** + * String 查询 + * + * @param columns 列 + */ + default Children select(String... columns) { + getSelectColum().addAll(Arrays.stream(columns).map(SelectString::new).collect(Collectors.toList())); + return getChildren(); + } + /** * 说明: * 比如我们需要查询用户表有10个字段,然而我们只需要3个就够了,用mybatis-plus提供的select

    diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/QueryJoin.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/QueryJoin.java index d5aee0f..0734491 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/QueryJoin.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/QueryJoin.java @@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.github.yulichang.interfaces.MPJBaseJoin; import com.github.yulichang.toolkit.Constant; import com.github.yulichang.toolkit.LambdaUtils; +import com.github.yulichang.wrapper.MPJAbstractLambdaWrapper; +import com.github.yulichang.wrapper.MPJLambdaWrapper; + +import java.util.function.BiConsumer; /** * @author yulichang @@ -40,7 +44,7 @@ public interface QueryJoin extends MPJBaseJoin { * @param clazz 关联实体类 * @param function 条件 */ - default Children leftJoin(Class clazz, WrapperFunction function) { + default Children leftJoin(Class clazz, WrapperFunction> function) { return join(Constant.LEFT_JOIN, clazz, function); } @@ -51,7 +55,7 @@ public interface QueryJoin extends MPJBaseJoin { * @param left 条件 * @param right 条件 */ - default Children leftJoin(Class clazz, SFunction left, SFunction right, WrapperFunction ext) { + default Children leftJoin(Class clazz, SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.LEFT_JOIN, clazz, left, right, ext); } @@ -61,7 +65,7 @@ public interface QueryJoin extends MPJBaseJoin { * @param left 条件 * @param right 条件 */ - default Children leftJoin(SFunction left, SFunction right, WrapperFunction ext) { + default Children leftJoin(SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.LEFT_JOIN, left, right, ext); } @@ -73,7 +77,7 @@ public interface QueryJoin extends MPJBaseJoin { * @param clazz 关联实体类 * @param consumer 条件 */ - default Children leftJoin(Class clazz, WrapperBiConsumer consumer) { + default Children leftJoin(Class clazz, BiConsumer, MPJLambdaWrapper> consumer) { return join(Constant.LEFT_JOIN, clazz, consumer); } @@ -94,28 +98,28 @@ public interface QueryJoin extends MPJBaseJoin { /** * ignore 参考 left join */ - default Children rightJoin(Class clazz, WrapperFunction function) { + default Children rightJoin(Class clazz, WrapperFunction> function) { return join(Constant.RIGHT_JOIN, clazz, function); } /** * ignore 参考 left join */ - default Children rightJoin(Class clazz, SFunction left, SFunction right, WrapperFunction ext) { + default Children rightJoin(Class clazz, SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.RIGHT_JOIN, clazz, left, right, ext); } /** * ignore 参考 left join */ - default Children rightJoin(SFunction left, SFunction right, WrapperFunction ext) { + default Children rightJoin(SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.RIGHT_JOIN, left, right, ext); } /** * ignore 参考 left join */ - default Children rightJoin(Class clazz, WrapperBiConsumer consumer) { + default Children rightJoin(Class clazz, BiConsumer, MPJLambdaWrapper> consumer) { return join(Constant.RIGHT_JOIN, clazz, consumer); } @@ -137,28 +141,28 @@ public interface QueryJoin extends MPJBaseJoin { /** * ignore 参考 left join */ - default Children innerJoin(Class clazz, WrapperFunction function) { + default Children innerJoin(Class clazz, WrapperFunction> function) { return join(Constant.INNER_JOIN, clazz, function); } /** * ignore 参考 left join */ - default Children innerJoin(Class clazz, SFunction left, SFunction right, WrapperFunction ext) { + default Children innerJoin(Class clazz, SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.INNER_JOIN, clazz, left, right, ext); } /** * ignore 参考 left join */ - default Children innerJoin(SFunction left, SFunction right, WrapperFunction ext) { + default Children innerJoin(SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.INNER_JOIN, left, right, ext); } /** * ignore 参考 left join */ - default Children innerJoin(Class clazz, WrapperBiConsumer consumer) { + default Children innerJoin(Class clazz, BiConsumer, MPJLambdaWrapper> consumer) { return join(Constant.INNER_JOIN, clazz, consumer); } @@ -180,28 +184,28 @@ public interface QueryJoin extends MPJBaseJoin { /** * ignore 参考 left join */ - default Children fullJoin(Class clazz, WrapperFunction function) { + default Children fullJoin(Class clazz, WrapperFunction> function) { return join(Constant.FULL_JOIN, clazz, function); } /** * ignore 参考 left join */ - default Children fullJoin(Class clazz, SFunction left, SFunction right, WrapperFunction ext) { + default Children fullJoin(Class clazz, SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.FULL_JOIN, clazz, left, right, ext); } /** * ignore 参考 left join */ - default Children fullJoin(SFunction left, SFunction right, WrapperFunction ext) { + default Children fullJoin(SFunction left, SFunction right, WrapperFunction> ext) { return join(Constant.FULL_JOIN, left, right, ext); } /** * ignore 参考 left join */ - default Children fullJoin(Class clazz, WrapperBiConsumer consumer) { + default Children fullJoin(Class clazz, BiConsumer, MPJLambdaWrapper> consumer) { return join(Constant.FULL_JOIN, clazz, consumer); } @@ -238,7 +242,7 @@ public interface QueryJoin extends MPJBaseJoin { * @param clazz 关联实体类 * @param function 条件 */ - default Children join(String keyWord, Class clazz, WrapperFunction function) { + default Children join(String keyWord, Class clazz, WrapperFunction> function) { return join(keyWord, clazz, (on, e) -> function.apply(on)); } @@ -249,7 +253,7 @@ public interface QueryJoin extends MPJBaseJoin { * @param left 条件 * @param right 条件 */ - default Children join(String keyWord, Class clazz, SFunction left, SFunction right, WrapperFunction ext) { + default Children join(String keyWord, Class clazz, SFunction left, SFunction right, WrapperFunction> ext) { return join(keyWord, clazz, (on, e) -> { on.eq(left, right); ext.apply(e); @@ -262,12 +266,12 @@ public interface QueryJoin extends MPJBaseJoin { * @param left 条件 * @param right 条件 */ - default Children join(String keyWord, SFunction left, SFunction right, WrapperFunction ext) { + default Children join(String keyWord, SFunction left, SFunction right, WrapperFunction> ext) { return join(keyWord, LambdaUtils.getEntityClass(left), left, right, ext); } /** * 内部使用, 不建议直接调用 */ - Children join(String keyWord, Class clazz, WrapperBiConsumer consumer); + Children join(String keyWord, Class clazz, BiConsumer, MPJLambdaWrapper> consumer); } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperBiConsumer.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperBiConsumer.java deleted file mode 100644 index fba0b98..0000000 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperBiConsumer.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.github.yulichang.wrapper.interfaces; - -import com.github.yulichang.wrapper.MPJLambdaWrapper; - -@FunctionalInterface -public interface WrapperBiConsumer { - - void accept(MPJLambdaWrapper on, MPJLambdaWrapper ext); -} diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperFunction.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperFunction.java index 19a7f5a..6ea8aad 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperFunction.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/WrapperFunction.java @@ -1,7 +1,5 @@ package com.github.yulichang.wrapper.interfaces; -import com.github.yulichang.wrapper.MPJLambdaWrapper; - /** * on function * @@ -11,5 +9,5 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; @FunctionalInterface public interface WrapperFunction { - MPJLambdaWrapper apply(MPJLambdaWrapper wrapper); + T apply(T wrapper); } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java index 498a53e..973a507 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/Select.java @@ -41,4 +41,6 @@ public interface Select { BaseFuncEnum getFunc(); boolean isLabel(); + + boolean isStr(); } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectAlias.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectAlias.java index 7732541..185956f 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectAlias.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectAlias.java @@ -92,4 +92,9 @@ public class SelectAlias implements Select { public boolean isLabel() { return false; } + + @Override + public boolean isStr() { + return false; + } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectFunc.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectFunc.java index 98ea88b..9db55ee 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectFunc.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectFunc.java @@ -98,4 +98,9 @@ public class SelectFunc implements Select { public boolean isLabel() { return false; } + + @Override + public boolean isStr() { + return false; + } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java index 703a1a5..9d85889 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectLabel.java @@ -116,4 +116,9 @@ public class SelectLabel implements Select { public boolean isLabel() { return true; } + + @Override + public boolean isStr() { + return false; + } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectNormal.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectNormal.java index 038cf6c..5c0e1a6 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectNormal.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectNormal.java @@ -93,4 +93,9 @@ public class SelectNormal implements Select { public boolean isLabel() { return false; } + + @Override + public boolean isStr() { + return false; + } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectString.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectString.java new file mode 100644 index 0000000..e76f102 --- /dev/null +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectString.java @@ -0,0 +1,99 @@ +package com.github.yulichang.wrapper.segments; + +import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; +import com.github.yulichang.wrapper.enums.BaseFuncEnum; +import org.apache.ibatis.type.TypeHandler; + +/** + * 自定义字符串列 + * + * @author yulichang + * @since 1.3.12 + */ +public class SelectString implements Select { + private final String column; + + public SelectString(String column) { + this.column = column; + } + + @Override + public Class getClazz() { + return null; + } + + @Override + public String getIndex() { + return null; + } + + @Override + public boolean isPk() { + return false; + } + + @Override + public String getColumn() { + return column; + } + + @Override + public Class getColumnType() { + return null; + } + + @Override + public String getTagColumn() { + return null; + } + + @Override + public String getColumProperty() { + return null; + } + + @Override + public boolean hasTypeHandle() { + return false; + } + + @Override + public TypeHandler getTypeHandle() { + return null; + } + + @Override + public boolean isHasAlias() { + return false; + } + + @Override + public String getAlias() { + return null; + } + + @Override + public TableFieldInfo getTableFieldInfo() { + return null; + } + + @Override + public boolean isFunc() { + return false; + } + + @Override + public BaseFuncEnum getFunc() { + return null; + } + + @Override + public boolean isLabel() { + return false; + } + + @Override + public boolean isStr() { + return true; + } +}