mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
代码调整
This commit is contained in:
parent
14ea2c45b0
commit
1f3a73056d
@ -8,9 +8,9 @@
|
||||
<artifactId>mybatis-plus-join-adapter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>mybatis-plus-join-adapter-v320</artifactId>
|
||||
<artifactId>mybatis-plus-join-adapter-v312</artifactId>
|
||||
<version>${revision}</version>
|
||||
<name>mybatis-plus-join-adapter-v320</name>
|
||||
<name>mybatis-plus-join-adapter-v312</name>
|
||||
|
||||
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
||||
<url>https://github.com/yulichang/mybatis-plus-join</url>
|
@ -1,4 +1,4 @@
|
||||
package com.github.yulichang.adapter.v320;
|
||||
package com.github.yulichang.adapter.v312;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
@ -24,7 +24,7 @@ import java.util.function.Supplier;
|
||||
* @author yulichang
|
||||
* @since 1.4.3
|
||||
*/
|
||||
public class Adapter320 implements IAdapter {
|
||||
public class Adapter312 implements IAdapter {
|
||||
|
||||
@Override
|
||||
public boolean mpjHasLogic(TableInfo tableInfo) {
|
@ -14,7 +14,7 @@
|
||||
|
||||
<modules>
|
||||
<module>mybatis-plus-join-adapter-base</module>
|
||||
<module>mybatis-plus-join-adapter-v320</module>
|
||||
<module>mybatis-plus-join-adapter-v312</module>
|
||||
<module>mybatis-plus-join-adapter-v33x</module>
|
||||
<module>mybatis-plus-join-adapter-v3431</module>
|
||||
<module>mybatis-plus-join-adapter-v352</module>
|
||||
|
@ -46,7 +46,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis.plus.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
@ -41,7 +41,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-adapter-v320</artifactId>
|
||||
<artifactId>mybatis-plus-join-adapter-v312</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -3,7 +3,7 @@ package com.github.yulichang.adapter;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
|
||||
import com.github.yulichang.adapter.base.IAdapter;
|
||||
import com.github.yulichang.adapter.base.tookit.VersionUtils;
|
||||
import com.github.yulichang.adapter.v320.Adapter320;
|
||||
import com.github.yulichang.adapter.v312.Adapter312;
|
||||
import com.github.yulichang.adapter.v33x.Adapter33x;
|
||||
import com.github.yulichang.adapter.v3431.Adapter3431;
|
||||
import com.github.yulichang.adapter.v355.Adapter355;
|
||||
@ -33,10 +33,10 @@ public class AdapterHelper {
|
||||
adapter = new Adapter3431();
|
||||
} else if (VersionUtils.compare(version, "3.3.0") >= 0) {
|
||||
adapter = new Adapter33x();
|
||||
} else if (VersionUtils.compare(version, "3.2.0") >= 0) {
|
||||
adapter = new Adapter320();
|
||||
} else if (VersionUtils.compare(version, "3.1.2") >= 0) {
|
||||
adapter = new Adapter312();
|
||||
} else {
|
||||
throw ExceptionUtils.mpe("MPJ需要MP版本3.2.0+,当前MP版本%s", version);
|
||||
throw ExceptionUtils.mpe("MPJ需要MP版本3.1.2+,当前MP版本%s", version);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,14 +443,7 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
public <R> Children join(String keyWord, Class<R> clazz, MConsumer<MPJLambdaWrapper<R>> table, String tableAlias, BiConsumer<JoinAbstractLambdaWrapper<T, ?>, Children> consumer) {
|
||||
String tabName;
|
||||
if (table != null) {
|
||||
MPJLambdaWrapper<R> tableWrapper = new MPJLambdaWrapper<R>(null, clazz, SharedString.emptyString(),
|
||||
paramNameSeq, paramNameValuePairs, new MergeSegments(), new SharedString(this.paramAlias
|
||||
.getStringValue()), SharedString.emptyString(), SharedString.emptyString(), SharedString.emptyString(),
|
||||
new TableList(), null, null, null, null, ifExists) {
|
||||
};
|
||||
tableWrapper.tableList.setAlias(ConfigProperties.tableAlias);
|
||||
tableWrapper.tableList.setRootClass(clazz);
|
||||
|
||||
MPJLambdaWrapper<R> tableWrapper = fromInstance(clazz);
|
||||
table.accept(tableWrapper);
|
||||
if (StrUtils.isBlank(tableWrapper.getSqlSelect())) {
|
||||
tableWrapper.selectAll();
|
||||
|
@ -3,7 +3,6 @@ package com.github.yulichang.wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
|
||||
import com.baomidou.mybatisplus.core.conditions.SharedString;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.interfaces.Nested;
|
||||
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
|
||||
import com.baomidou.mybatisplus.core.enums.SqlKeyword;
|
||||
import com.baomidou.mybatisplus.core.enums.SqlLike;
|
||||
@ -182,9 +181,9 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
||||
.getStringValue()), SharedString.emptyString(), SharedString.emptyString(), SharedString.emptyString(),
|
||||
new TableList(), null, null, null, null, ifExists) {
|
||||
};
|
||||
wrapper.tableList.setAlias(this.alias);
|
||||
wrapper.tableList.setAlias(ConfigProperties.tableAlias);
|
||||
wrapper.tableList.setRootClass(clazz);
|
||||
wrapper.alias = this.alias;
|
||||
wrapper.alias = ConfigProperties.tableAlias;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2024, 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.function.Consumer;
|
||||
|
||||
/**
|
||||
* 查询条件封装
|
||||
* <p>嵌套</p>
|
||||
* <li>泛型 Param 是具体需要运行函数的类(也是 wrapper 的子类)</li>
|
||||
*
|
||||
* @author hubin miemie HCL
|
||||
* @since 2017-05-26
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface Nested<Param, Children> extends Serializable {
|
||||
|
||||
/**
|
||||
* AND 嵌套
|
||||
* <p>
|
||||
* 例: and(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
default Children and(Consumer<Param> consumer) {
|
||||
return and(true, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* AND 嵌套
|
||||
* <p>
|
||||
* 例: and(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param condition 执行条件
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
Children and(boolean condition, Consumer<Param> consumer);
|
||||
|
||||
/**
|
||||
* OR 嵌套
|
||||
* <p>
|
||||
* 例: or(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
default Children or(Consumer<Param> consumer) {
|
||||
return or(true, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* OR 嵌套
|
||||
* <p>
|
||||
* 例: or(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param condition 执行条件
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
Children or(boolean condition, Consumer<Param> consumer);
|
||||
|
||||
/**
|
||||
* 正常嵌套 不带 AND 或者 OR
|
||||
* <p>
|
||||
* 例: nested(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
default Children nested(Consumer<Param> consumer) {
|
||||
return nested(true, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常嵌套 不带 AND 或者 OR
|
||||
* <p>
|
||||
* 例: nested(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param condition 执行条件
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
Children nested(boolean condition, Consumer<Param> consumer);
|
||||
|
||||
/**
|
||||
* not嵌套
|
||||
* <p>
|
||||
* 例: not(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
default Children not(Consumer<Param> consumer) {
|
||||
return not(true, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* not嵌套
|
||||
* <p>
|
||||
* 例: not(i -> i.eq("name", "李白").ne("status", "活着"))
|
||||
* </p>
|
||||
*
|
||||
* @param condition 执行条件
|
||||
* @param consumer 消费函数
|
||||
* @return children
|
||||
*/
|
||||
Children not(boolean condition, Consumer<Param> consumer);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user