mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
pom
This commit is contained in:
parent
48b12a324c
commit
1f0ada7593
@ -88,12 +88,6 @@
|
||||
<version>1.8.21</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>1.8.21</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.yulichang.adapter;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisPlusVersion;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.github.yulichang.adapter.base.ITableInfoAdapter;
|
||||
import com.github.yulichang.adapter.v33x.TableInfoAdapterV33x;
|
||||
|
||||
@ -10,11 +11,18 @@ import com.github.yulichang.adapter.v33x.TableInfoAdapterV33x;
|
||||
*/
|
||||
public class AdapterHelper {
|
||||
|
||||
public static ITableInfoAdapter getTableInfoAdapter() {
|
||||
private static final ITableInfoAdapter adapter;
|
||||
|
||||
static {
|
||||
String version = MybatisPlusVersion.getVersion();
|
||||
if (version.startsWith("3.3.")) {
|
||||
return new TableInfoAdapterV33x();
|
||||
}
|
||||
return new TableInfoAdapter();
|
||||
if (StringUtils.isNotBlank(version) && version.startsWith("3.3.")) {
|
||||
adapter = new TableInfoAdapterV33x();
|
||||
} else {
|
||||
adapter = new TableInfoAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
public static ITableInfoAdapter getTableInfoAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ import static java.util.stream.Collectors.joining;
|
||||
* @author yulichang
|
||||
*/
|
||||
@SuppressWarnings({"DuplicatedCode", "unused"})
|
||||
public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLambdaWrapper<T, Children>>
|
||||
extends MPJAbstractWrapper<T, Children> implements QueryJoin<Children, T> {
|
||||
public abstract class KtAbstractLambdaWrapper<T, Children extends KtAbstractLambdaWrapper<T, Children>>
|
||||
extends KtAbstractWrapper<T, Children> implements QueryJoin<Children, T> {
|
||||
|
||||
/**
|
||||
* 主表别名
|
||||
@ -98,14 +98,14 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
||||
/**
|
||||
* 推荐使用 带 class 的构造方法
|
||||
*/
|
||||
public MPJAbstractLambdaWrapper() {
|
||||
public KtAbstractLambdaWrapper() {
|
||||
initNeed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐使用此构造方法
|
||||
*/
|
||||
public MPJAbstractLambdaWrapper(Class<T> clazz) {
|
||||
public KtAbstractLambdaWrapper(Class<T> clazz) {
|
||||
initNeed();
|
||||
setEntityClass(clazz);
|
||||
tableList.setRootClass(clazz);
|
||||
@ -116,7 +116,7 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
||||
*
|
||||
* @param entity 主表实体
|
||||
*/
|
||||
public MPJAbstractLambdaWrapper(T entity) {
|
||||
public KtAbstractLambdaWrapper(T entity) {
|
||||
initNeed();
|
||||
setEntity(entity);
|
||||
if (entity != null) {
|
||||
@ -127,7 +127,7 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
||||
/**
|
||||
* 自定义主表别名
|
||||
*/
|
||||
public MPJAbstractLambdaWrapper(String alias) {
|
||||
public KtAbstractLambdaWrapper(String alias) {
|
||||
this.alias = alias;
|
||||
initNeed();
|
||||
tableList.setAlias(alias);
|
||||
@ -139,7 +139,7 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
||||
* @param clazz 主表class类
|
||||
* @param alias 主表别名
|
||||
*/
|
||||
public MPJAbstractLambdaWrapper(Class<T> clazz, String alias) {
|
||||
public KtAbstractLambdaWrapper(Class<T> clazz, String alias) {
|
||||
this.alias = alias;
|
||||
setEntityClass(clazz);
|
||||
initNeed();
|
||||
@ -153,7 +153,7 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
||||
* @param entity 主表实体类
|
||||
* @param alias 主表别名
|
||||
*/
|
||||
public MPJAbstractLambdaWrapper(T entity, String alias) {
|
||||
public KtAbstractLambdaWrapper(T entity, String alias) {
|
||||
this.alias = alias;
|
||||
setEntity(entity);
|
||||
initNeed();
|
||||
@ -371,7 +371,7 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
||||
* 内部调用, 不建议使用
|
||||
*/
|
||||
@Override
|
||||
public Children join(String keyWord, Class<?> clazz, String tableAlias, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
public Children join(String keyWord, Class<?> clazz, String tableAlias, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
Integer oldIndex = this.getIndex();
|
||||
int newIndex = tableIndex;
|
||||
TableInfo info = TableHelper.get(clazz);
|
@ -38,7 +38,7 @@ import static java.util.stream.Collectors.joining;
|
||||
* @author yulichang
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<T, Children>> extends Wrapper<T>
|
||||
public abstract class KtAbstractWrapper<T, Children extends KtAbstractWrapper<T, Children>> extends Wrapper<T>
|
||||
implements Compare<Children>, Nested<Children, Children>, Join<Children>, Func<Children>, OnCompare<Children>,
|
||||
CompareStr<Children, String>, FuncStr<Children, String> {
|
||||
|
@ -21,7 +21,8 @@ import java.util.stream.Collectors;
|
||||
* @author yulichang
|
||||
* @since 1.4.5
|
||||
*/
|
||||
public class KtDeleteJoinWrapper<T> extends MPJAbstractLambdaWrapper<T, KtDeleteJoinWrapper<T>> {
|
||||
@SuppressWarnings({"unused", "DuplicatedCode"})
|
||||
public class KtDeleteJoinWrapper<T> extends KtAbstractLambdaWrapper<T, KtDeleteJoinWrapper<T>> {
|
||||
|
||||
/**
|
||||
* 删除表
|
||||
@ -69,7 +70,6 @@ public class KtDeleteJoinWrapper<T> extends MPJAbstractLambdaWrapper<T, KtDelete
|
||||
* 获取删除的表
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public String getDeleteSql() {
|
||||
if (StringUtils.isNotBlank(this.deleteSql.getStringValue())) {
|
||||
return this.deleteSql.getStringValue();
|
||||
|
@ -30,8 +30,8 @@ import java.util.stream.Collectors;
|
||||
* @author yulichang
|
||||
* @since 1.4.6
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
public class KtLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, KtLambdaWrapper<T>> implements
|
||||
@SuppressWarnings({"unused", "unchecked", "rawtypes"})
|
||||
public class KtLambdaWrapper<T> extends KtAbstractLambdaWrapper<T, KtLambdaWrapper<T>> implements
|
||||
Query<KtLambdaWrapper<T>>, QueryLabel<KtLambdaWrapper<T>>, Chain<T>, SelectWrapper<T, KtLambdaWrapper<T>> {
|
||||
|
||||
/**
|
||||
@ -250,6 +250,7 @@ public class KtLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, KtLambdaWrap
|
||||
* 查询条件 SQL 片段
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public String getSqlSelect() {
|
||||
if (StringUtils.isBlank(sqlSelect.getStringValue()) && CollectionUtils.isNotEmpty(selectColumns)) {
|
||||
String s = selectColumns.stream().map(i -> {
|
||||
|
@ -27,8 +27,8 @@ import java.util.stream.Collectors;
|
||||
* @author yulichang
|
||||
* @since 1.4.6
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class KtUpdateJoinWrapper<T> extends MPJAbstractLambdaWrapper<T, KtUpdateJoinWrapper<T>>
|
||||
@SuppressWarnings({"unused", "DuplicatedCode"})
|
||||
public class KtUpdateJoinWrapper<T> extends KtAbstractLambdaWrapper<T, KtUpdateJoinWrapper<T>>
|
||||
implements Update<KtUpdateJoinWrapper<T>> {
|
||||
/**
|
||||
* SQL 更新字段内容,例如:name='1', age=2
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.yulichang.kt.interfaces;
|
||||
|
||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
||||
import com.github.yulichang.kt.MPJAbstractLambdaWrapper;
|
||||
import com.github.yulichang.kt.KtAbstractLambdaWrapper;
|
||||
import com.github.yulichang.query.interfaces.StringJoin;
|
||||
import com.github.yulichang.toolkit.Constant;
|
||||
import com.github.yulichang.wrapper.interfaces.WrapperFunction;
|
||||
@ -34,7 +34,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件`
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children leftJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.LEFT_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param consumer 条件
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children leftJoin(Class<?> clazz, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.LEFT_JOIN, clazz, consumer);
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children leftJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.LEFT_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param consumer 条件
|
||||
*/
|
||||
default Children leftJoin(Class<?> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children leftJoin(Class<?> clazz, String alias, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.LEFT_JOIN, clazz, alias, consumer);
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children rightJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children rightJoin(Class<?> clazz, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, consumer);
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children rightJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children rightJoin(Class<?> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children rightJoin(Class<?> clazz, String alias, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.RIGHT_JOIN, clazz, alias, consumer);
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children innerJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.INNER_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children innerJoin(Class<?> clazz, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.INNER_JOIN, clazz, consumer);
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children innerJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.INNER_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children innerJoin(Class<?> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children innerJoin(Class<?> clazz, String alias, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.INNER_JOIN, clazz, alias, consumer);
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children fullJoin(Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.FULL_JOIN, clazz, function);
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children fullJoin(Class<?> clazz, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.FULL_JOIN, clazz, consumer);
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children fullJoin(Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(Constant.FULL_JOIN, clazz, alias, function);
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* ignore 参考 left join
|
||||
*/
|
||||
default Children fullJoin(Class<?> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children fullJoin(Class<?> clazz, String alias, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(Constant.FULL_JOIN, clazz, alias, consumer);
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children join(String keyWord, Class<?> clazz, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(keyWord, clazz, (on, e) -> function.apply(on));
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
* @param clazz 关联实体类
|
||||
* @param function 条件
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<?, ?>> function) {
|
||||
default Children join(String keyWord, Class<?> clazz, String alias, WrapperFunction<KtAbstractLambdaWrapper<?, ?>> function) {
|
||||
return join(keyWord, clazz, alias, (on, e) -> function.apply(on));
|
||||
}
|
||||
|
||||
@ -362,12 +362,12 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
||||
/**
|
||||
* 内部使用, 不建议直接调用
|
||||
*/
|
||||
default Children join(String keyWord, Class<?> clazz, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
default Children join(String keyWord, Class<?> clazz, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer) {
|
||||
return join(keyWord, clazz, null, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部使用, 不建议直接调用
|
||||
*/
|
||||
Children join(String keyWord, Class<?> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<?, ?>, Children> consumer);
|
||||
Children join(String keyWord, Class<?> clazz, String alias, BiConsumer<KtAbstractLambdaWrapper<?, ?>, Children> consumer);
|
||||
}
|
||||
|
@ -20,9 +20,11 @@
|
||||
<modules>
|
||||
<module>test-base</module>
|
||||
<module>test-join</module>
|
||||
<module>test-kotlin</module>
|
||||
<module>test-collection</module>
|
||||
<module>test-mapping</module>
|
||||
|
||||
<!-- 以下两个模块需要jdk17+, 使用jdk8会出现编译错误, 如果有安装jdk17+可以打开这两个模块 -->
|
||||
<!-- <module>test-kotlin</module>-->
|
||||
<!-- <module>test-springboot3-jdk17</module>-->
|
||||
</modules>
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@DynamicTableName
|
||||
@FieldNameConstants
|
||||
@TableName(value = "`user`", autoResultMap = true)
|
||||
@TableName(value = "`user`")
|
||||
public class UserDO extends ID<Integer> implements Serializable {
|
||||
|
||||
private Integer pid;
|
||||
|
@ -7,12 +7,7 @@
|
||||
<artifactId>mybatis-plus-join-test</artifactId>
|
||||
<version>1.4.5</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>test-kotlin</artifactId>
|
||||
<version>1.4.5</version>
|
||||
|
||||
<name>test-kotlin</name>
|
||||
<description>test-kotlin</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
Loading…
x
Reference in New Issue
Block a user