diff --git a/.github/workflows/depoly.yml b/.github/workflows/depoly.yml
index eab6a49..145518c 100644
--- a/.github/workflows/depoly.yml
+++ b/.github/workflows/depoly.yml
@@ -1,8 +1,7 @@
name: Maven Package
on:
- release:
- types: [ created ]
+ push: tags
jobs:
build:
diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml
index 5c09ac2..1edda92 100644
--- a/.github/workflows/snapshot.yml
+++ b/.github/workflows/snapshot.yml
@@ -32,7 +32,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Publish to Apache Maven Central
- run: mvn deploy -Psnapshot
+ run: mvn deploy -Prelease -Psnapshot
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
diff --git a/README-zh.md b/README-zh.md
index 2c51921..7d64903 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -10,7 +10,10 @@
-
+
+
+
+
@@ -115,12 +118,16 @@ MPJLambdaWrapper其他功能
*
一对一,一对多使用
-* 简单的SQL函数使用
-* ON语句多条件支持
+*
+ 简单的SQL函数使用
+*
+ ON语句多条件支持
* 其他全部功能请参考使用文档
# 使用文档 wiki
+
# 用爱发电
+
diff --git a/README.md b/README.md
index f499b5d..a1db25e 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,10 @@
-
+
+
+
+
diff --git a/mybatis-plus-join-core/pom.xml b/mybatis-plus-join-core/pom.xml
index c82d434..fcc76fe 100644
--- a/mybatis-plus-join-core/pom.xml
+++ b/mybatis-plus-join-core/pom.xml
@@ -64,6 +64,11 @@
mybatis-plus-join-adapter-v355
${revision}
+
+ com.github.yulichang
+ mybatis-plus-join-wrapper-ext
+ ${revision}
+
com.baomidou
mybatis-plus-extension
@@ -99,5 +104,19 @@
-
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ true
+
+
+
+
+
+
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java
index dc5f62d..f61326f 100644
--- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java
@@ -3,6 +3,7 @@ package com.github.yulichang.config;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.github.yulichang.interceptor.MPJInterceptor;
import com.github.yulichang.toolkit.InterceptorList;
+import com.github.yulichang.toolkit.MybatisJoinPlusVersion;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.plugin.Interceptor;
@@ -30,7 +31,7 @@ public class MPJInterceptorConfig {
System.out.println(" _ _ |_ _ _|_. ___ _ | _ . _ . _ \n" +
"| | |\\/|_)(_| | |_\\ |_)||_|_\\ | (_) | | | \n" +
" / | /\n" +
- " 1.5.2-SNAPSHOT");
+ " " + MybatisJoinPlusVersion.getVersion());
}
}
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java
index bb768e8..463417c 100644
--- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/query/MPJQueryWrapper.java
@@ -350,7 +350,8 @@ public class MPJQueryWrapper extends AbstractWrapper lambda() {
return new MPJLambdaQueryWrapper<>(getEntity(), getEntityClass(), from, sqlSelect, paramNameSeq, paramNameValuePairs,
- expression, lastSql, sqlComment, getSqlFirstField(), selectColumns, ignoreColumns, selectDistinct, ifExists);
+ expression, lastSql, sqlComment, getSqlFirstField(), selectColumns, ignoreColumns, selectDistinct, ifExists)
+ .setAlias(this.alias);
}
@Override
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MybatisJoinPlusVersion.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MybatisJoinPlusVersion.java
new file mode 100644
index 0000000..2f046b5
--- /dev/null
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MybatisJoinPlusVersion.java
@@ -0,0 +1,53 @@
+package com.github.yulichang.toolkit;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.CodeSource;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+
+/**
+ * copy {@link com.baomidou.mybatisplus.core.MybatisPlusVersion}
+ *
+ * @since 1.5.2
+ */
+public class MybatisJoinPlusVersion {
+
+ private MybatisJoinPlusVersion() {
+ }
+
+ public static String getVersion() {
+ return determineSpringBootVersion();
+ }
+
+ private static String determineSpringBootVersion() {
+ final Package pkg = MybatisJoinPlusVersion.class.getPackage();
+ if (pkg != null && pkg.getImplementationVersion() != null) {
+ return pkg.getImplementationVersion();
+ }
+ CodeSource codeSource = MybatisJoinPlusVersion.class.getProtectionDomain().getCodeSource();
+ if (codeSource == null) {
+ return null;
+ }
+ URL codeSourceLocation = codeSource.getLocation();
+ try {
+ URLConnection connection = codeSourceLocation.openConnection();
+ if (connection instanceof JarURLConnection) {
+ return getImplementationVersion(((JarURLConnection) connection).getJarFile());
+ }
+ try (JarFile jarFile = new JarFile(new File(codeSourceLocation.toURI()))) {
+ return getImplementationVersion(jarFile);
+ }
+ } catch (Exception ex) {
+ return null;
+ }
+ }
+
+ private static String getImplementationVersion(JarFile jarFile) throws IOException {
+ return jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION);
+ }
+
+}
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java
index 52f41af..c69a334 100644
--- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java
@@ -14,6 +14,7 @@ import com.github.yulichang.config.enums.LogicDelTypeEnum;
import com.github.yulichang.toolkit.*;
import com.github.yulichang.toolkit.support.ColumnCache;
import com.github.yulichang.wrapper.enums.PrefixEnum;
+import com.github.yulichang.wrapper.ext.Ext;
import com.github.yulichang.wrapper.interfaces.MConsumer;
import com.github.yulichang.wrapper.interfaces.MFunction;
import com.github.yulichang.wrapper.interfaces.QueryJoin;
@@ -40,7 +41,7 @@ import static java.util.stream.Collectors.joining;
*/
@SuppressWarnings({"DuplicatedCode", "unused"})
public abstract class JoinAbstractLambdaWrapper>
- extends JoinAbstractWrapper implements QueryJoin {
+ extends JoinAbstractWrapper implements QueryJoin, Ext {
/**
* 是否存在对一或对多
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 44045eb..cf4a320 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
@@ -2,11 +2,13 @@ package com.github.yulichang.wrapper;
import com.baomidou.mybatisplus.core.conditions.SharedString;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
-import com.baomidou.mybatisplus.core.toolkit.*;
+import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
+import com.baomidou.mybatisplus.core.toolkit.Assert;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.github.yulichang.config.ConfigProperties;
import com.github.yulichang.toolkit.*;
-import com.github.yulichang.toolkit.LambdaUtils;
import com.github.yulichang.toolkit.support.ColumnCache;
import com.github.yulichang.wrapper.enums.IfExistsSqlKeyWordEnum;
import com.github.yulichang.wrapper.interfaces.*;
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/IExt.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/IExt.java
new file mode 100644
index 0000000..7dc6c11
--- /dev/null
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/IExt.java
@@ -0,0 +1,14 @@
+package com.github.yulichang.wrapper.interfaces;
+
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+
+/**
+ * @param wrapper
+ * @auther yulichang
+ * @since 1.5.2
+ */
+public interface IExt> {
+
+ Children getChildren();
+}
+
diff --git a/mybatis-plus-join-test/test-join/pom.xml b/mybatis-plus-join-test/test-join/pom.xml
index a1e4bdd..b0bad7c 100644
--- a/mybatis-plus-join-test/test-join/pom.xml
+++ b/mybatis-plus-join-test/test-join/pom.xml
@@ -13,6 +13,17 @@
test-join
+
+ com.github.yulichang
+ mybatis-plus-join-boot-starter
+ ${revision}
+
+
+ com.github.yulichang
+ mybatis-plus-join-wrapper-ext
+
+
+
com.github.yulichang
test-base
@@ -39,5 +50,13 @@
mybatis-plus-join-processor
${revision}
+
+ ognl
+ ognl
+
+
+ org.javassist
+ javassist
+
diff --git a/mybatis-plus-join-test/test-join/src/main/java/com/github/yulichang/test/join/repository/UserCrudRepository.java b/mybatis-plus-join-test/test-join/src/main/java/com/github/yulichang/test/join/repository/UserCrudRepository.java
new file mode 100644
index 0000000..9201bff
--- /dev/null
+++ b/mybatis-plus-join-test/test-join/src/main/java/com/github/yulichang/test/join/repository/UserCrudRepository.java
@@ -0,0 +1,11 @@
+package com.github.yulichang.test.join.repository;
+
+import com.github.yulichang.repository.JoinCrudRepository;
+import com.github.yulichang.test.join.entity.UserDO;
+import com.github.yulichang.test.join.mapper.UserMapper;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class UserCrudRepository extends JoinCrudRepository {
+
+}
diff --git a/mybatis-plus-join-test/test-join/src/main/java/com/github/yulichang/wrapper/ext/Ext.java b/mybatis-plus-join-test/test-join/src/main/java/com/github/yulichang/wrapper/ext/Ext.java
new file mode 100644
index 0000000..e2355b6
--- /dev/null
+++ b/mybatis-plus-join-test/test-join/src/main/java/com/github/yulichang/wrapper/ext/Ext.java
@@ -0,0 +1,14 @@
+package com.github.yulichang.wrapper.ext;
+
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.github.yulichang.wrapper.interfaces.IExt;
+
+@SuppressWarnings("unused")
+public interface Ext> extends IExt {
+
+ default Children cccEq(SFunction c, Object val) {
+ getChildren().eq(c, val);
+ return getChildren();
+ }
+}
diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java
index 581dfa3..ee27b33 100644
--- a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java
+++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/QueryWrapperTest.java
@@ -128,4 +128,17 @@ class QueryWrapperTest {
System.out.println(userDO);
}
+ @Test
+ void test7() {
+ ThreadLocalUtils.set("SELECT tt.id AS idea, tt.user_id AS uuid, tt.tenant_id FROM user_tenant tt WHERE (tt.id <= ?) AND tt.tenant_id = 1");
+ MPJQueryWrapper wrapper = new MPJQueryWrapper()
+ .setAlias("tt")
+ .selectAll(UserTenantDO.class,"tt")
+ .le("tt.id ", 10);
+ System.out.println(wrapper.getAlias());
+ List userDO = userTenantMapper.selectJoinList(UserTenantDO.class, wrapper.lambda());
+ System.out.println(wrapper.getAlias());
+ System.out.println(userDO);
+ }
+
}
diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/ExtWrapperTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/ExtWrapperTest.java
new file mode 100644
index 0000000..1e948bd
--- /dev/null
+++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/ExtWrapperTest.java
@@ -0,0 +1,34 @@
+package com.github.yulichang.test.join.unit;
+
+import com.github.yulichang.test.join.entity.UserDO;
+import com.github.yulichang.test.util.Reset;
+import com.github.yulichang.test.util.ThreadLocalUtils;
+import com.github.yulichang.toolkit.JoinWrappers;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class ExtWrapperTest {
+
+
+ @BeforeEach
+ void setUp() {
+ Reset.reset();
+ }
+
+
+ @Test
+ void applyFunc() {
+ ThreadLocalUtils.set("SELECT t.id, t.pid, t.`name`, t.`json`, " +
+ "t.sex, t.head_img, t.create_time, t.address_id, " +
+ "t.address_id2, t.del, t.create_by, t.update_by " +
+ "FROM `user` t WHERE t.del = false AND (t.id = ?)");
+ MPJLambdaWrapper wrapper = JoinWrappers.lambda(UserDO.class)
+ .selectAll()
+ .cccEq(UserDO::getId, 1);
+ wrapper.list();
+ }
+
+}
diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/StringColumTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/StringColumTest.java
index 363ca40..a0600cc 100644
--- a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/StringColumTest.java
+++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/unit/StringColumTest.java
@@ -3,7 +3,7 @@ package com.github.yulichang.test.join.unit;
import com.github.yulichang.test.join.dto.UserDTO;
import com.github.yulichang.test.join.entity.AddressDO;
import com.github.yulichang.test.join.entity.UserDO;
-import com.github.yulichang.test.join.mapper.UserMapper;
+import com.github.yulichang.test.join.repository.UserCrudRepository;
import com.github.yulichang.test.util.Reset;
import com.github.yulichang.test.util.ThreadLocalUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -19,7 +19,7 @@ import java.util.List;
public class StringColumTest {
@Autowired
- private UserMapper userMapper;
+ private UserCrudRepository userCrudRepository;
@BeforeEach
void setUp() {
@@ -33,7 +33,7 @@ public class StringColumTest {
ThreadLocalUtils.set("SELECT (SELECT id FROM `user` u WHERE u.id = t.id) id, t.`name` AS PName, t.`name` PName, t.`name`," +
" (SELECT id FROM `user` u WHERE u.id = t.id), t1.id AS joina_id, t1.user_id, t1.area_id, t1.tel, " +
"t1.address, t1.del FROM `user` t LEFT JOIN address t1 ON (t1.user_id = t.id) WHERE t.del = false AND t1.del = false");
- List l3 = userMapper.selectJoinList(UserDTO.class, new MPJLambdaWrapper()
+ List l3 = userCrudRepository.selectJoinList(UserDTO.class, new MPJLambdaWrapper()
.select("(select id from `user` u where u.id = t.id) id")
.select("t.`name` as PName")
.select("t.`name` PName")
diff --git a/plugin/mybatis-plus-join-processor/pom.xml b/plugin/mybatis-plus-join-processor/pom.xml
index 6ec0127..75850fd 100644
--- a/plugin/mybatis-plus-join-processor/pom.xml
+++ b/plugin/mybatis-plus-join-processor/pom.xml
@@ -18,14 +18,12 @@
ognl
ognl
- 3.4.3
compile
true
org.javassist
javassist
- 3.30.2-GA
compile
true
diff --git a/plugin/mybatis-plus-join-solon-plugin/pom.xml b/plugin/mybatis-plus-join-solon-plugin/pom.xml
index 87dac5a..4204d07 100644
--- a/plugin/mybatis-plus-join-solon-plugin/pom.xml
+++ b/plugin/mybatis-plus-join-solon-plugin/pom.xml
@@ -9,6 +9,7 @@
${revision}
../../pom.xml
+ ${revision}
mybatis-plus-join-solon-plugin
diff --git a/plugin/mybatis-plus-join-wrapper-ext/pom.xml b/plugin/mybatis-plus-join-wrapper-ext/pom.xml
new file mode 100644
index 0000000..1c07b79
--- /dev/null
+++ b/plugin/mybatis-plus-join-wrapper-ext/pom.xml
@@ -0,0 +1,16 @@
+
+
+ 4.0.0
+
+ com.github.yulichang
+ mybatis-plus-join-root
+ ${revision}
+ ../../pom.xml
+
+ ${revision}
+
+ mybatis-plus-join-wrapper-ext
+
+
\ No newline at end of file
diff --git a/plugin/mybatis-plus-join-wrapper-ext/src/main/java/com/github/yulichang/wrapper/ext/Ext.java b/plugin/mybatis-plus-join-wrapper-ext/src/main/java/com/github/yulichang/wrapper/ext/Ext.java
new file mode 100644
index 0000000..9d393a6
--- /dev/null
+++ b/plugin/mybatis-plus-join-wrapper-ext/src/main/java/com/github/yulichang/wrapper/ext/Ext.java
@@ -0,0 +1,13 @@
+package com.github.yulichang.wrapper.ext;
+
+
+/**
+ * 自定义Wrapper扩展
+ *
+ * @param wrapper 一般是指 MPJLambdaWrapper
+ * @auther yulichang
+ * @since 1.5.2
+ */
+@SuppressWarnings("unused")
+public interface Ext {
+}
diff --git a/pom.xml b/pom.xml
index a594507..959f14c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,12 +38,14 @@
plugin/mybatis-plus-join-solon-plugin
plugin/mybatis-plus-join-processor
+ plugin/mybatis-plus-join-wrapper-ext
mybatis-plus-join-test
- 1.5.2-SNAPSHOT
+ 1.5.2
+ ${version}
3.5.9
17
@@ -66,82 +68,25 @@
import
pom
+
+ ognl
+ ognl
+ 3.4.3
+
+
+ org.javassist
+ javassist
+ 3.30.2-GA
+
snapshot
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- true
-
- maven
- https://oss.sonatype.org/
- true
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- attach-sources
-
- jar-no-fork
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- -Xdoclint:none
-
- UTF-8
- UTF-8
- UTF-8
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
-
-
- verify
-
- sign
-
-
-
- --pinentry-mode
- loopback
-
-
-
-
-
-
-
-
-
- maven
- https://oss.sonatype.org/content/repositories/snapshots
-
-
+
+ ${version}-SNAPSHOT
+
release