Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into snapshot
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
yulichang committed Oct 30, 2024
2 parents 30629ee + 5b61dfe commit eb3cecf
Show file tree
Hide file tree
Showing 22 changed files with 253 additions and 89 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/depoly.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Maven Package

on:
release:
types: [ created ]
push: tags

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
13 changes: 10 additions & 3 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
</p>
<p align="center">
<a href="https://central.sonatype.com/artifact/com.github.yulichang/mybatis-plus-join-boot-starter">
<img alt="maven" src="https://img.shields.io/maven-central/v/com.github.yulichang/mybatis-plus-join-boot-starter.svg?style=flat-square">
<img alt="Maven central" src="https://img.shields.io/maven-central/v/com.github.yulichang/mybatis-plus-join-boot-starter.svg?style=flat-square">
</a>
<a href="https://oss.sonatype.org/content/repositories/snapshots/com/github/yulichang/mybatis-plus-join-boot-starter/">
<img alt="Sonatype Nexus (Snapshots)" src="https://img.shields.io/nexus/s/https/oss.sonatype.org/com.github.yulichang/mybatis-plus-join-boot-starter.svg">
</a>
<a href="https://www.apache.org/licenses/LICENSE-2.0">
<img alt="code style" src="https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square">
Expand Down Expand Up @@ -115,12 +118,16 @@ MPJLambdaWrapper其他功能

* <a href="https://mybatis-plus-join.github.io/pages/core/lambda/select/selectCollection.html" target="_blank">
一对一,一对多使用</a>
* <a href="https://mybatis-plus-join.github.io/pages/core/lambda/select/selectFunc.html" target="_blank">简单的SQL函数使用</a>
* <a href="https://mybatis-plus-join.github.io/pages/core/lambda/join/leftJoin.html" target="_blank">ON语句多条件支持</a>
* <a href="https://mybatis-plus-join.github.io/pages/core/lambda/select/selectFunc.html" target="_blank">
简单的SQL函数使用</a>
* <a href="https://mybatis-plus-join.github.io/pages/core/lambda/join/leftJoin.html" target="_blank">
ON语句多条件支持</a>
* <a href="https://mybatis-plus-join.github.io" target="_blank">其他全部功能请参考使用文档</a>

# <a href="https://mybatis-plus-join.github.io" target="_blank">使用文档 wiki</a>

# 用爱发电

<a href="https://mybatis-plus-join.github.io/pages/quickstart/support.html" target="_blank">
<img alt="支持一下mybatis-plus-join" src="https://foruda.gitee.com/images/1717191488951888381/8463cfcd_2020985.png">
</a>
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
</p>
<p align="center">
<a href="https://central.sonatype.com/artifact/com.github.yulichang/mybatis-plus-join-boot-starter">
<img alt="maven" src="https://img.shields.io/maven-central/v/com.github.yulichang/mybatis-plus-join-boot-starter.svg?style=flat-square">
<img alt="Maven central" src="https://img.shields.io/maven-central/v/com.github.yulichang/mybatis-plus-join-boot-starter.svg?style=flat-square">
</a>
<a href="https://oss.sonatype.org/content/repositories/snapshots/com/github/yulichang/mybatis-plus-join-boot-starter/">
<img alt="Sonatype Nexus (Snapshots)" src="https://img.shields.io/nexus/s/https/oss.sonatype.org/com.github.yulichang/mybatis-plus-join-boot-starter.svg">
</a>
<a href="https://www.apache.org/licenses/LICENSE-2.0">
<img alt="code style" src="https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square">
Expand Down
21 changes: 20 additions & 1 deletion mybatis-plus-join-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
<artifactId>mybatis-plus-join-adapter-v355</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-wrapper-ext</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
Expand Down Expand Up @@ -99,5 +104,19 @@
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -30,7 +31,7 @@ public MPJInterceptorConfig(List<SqlSessionFactory> sqlSessionFactoryList, Boole
System.out.println(" _ _ |_ _ _|_. ___ _ | _ . _ . _ \n" +
"| | |\\/|_)(_| | |_\\ |_)||_|_\\ | (_) | | | \n" +
" / | /\n" +
" 1.5.2-SNAPSHOT");
" " + MybatisJoinPlusVersion.getVersion());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ public String getTableNameEnc(String tableName) {
*/
public MPJLambdaQueryWrapper<T> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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;
Expand All @@ -40,7 +41,7 @@
*/
@SuppressWarnings({"DuplicatedCode", "unused"})
public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstractLambdaWrapper<T, Children>>
extends JoinAbstractWrapper<T, Children> implements QueryJoin<Children, T> {
extends JoinAbstractWrapper<T, Children> implements QueryJoin<Children, T>, Ext<Children> {

/**
* 是否存在对一或对多
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

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.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.yulichang.wrapper.interfaces;

import com.github.yulichang.wrapper.MPJLambdaWrapper;

/**
* @param <Children> wrapper
* @auther yulichang
* @since 1.5.2
*/
public interface IExt<Children extends MPJLambdaWrapper<?>> {

Children getChildren();
}

19 changes: 19 additions & 0 deletions mybatis-plus-join-test/test-join/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
<artifactId>test-join</artifactId>

<dependencies>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>${revision}</version>
<exclusions>
<exclusion>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-wrapper-ext</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>test-base</artifactId>
Expand All @@ -39,5 +50,13 @@
<artifactId>mybatis-plus-join-processor</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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<UserMapper, UserDO> {

}
Original file line number Diff line number Diff line change
@@ -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<Children extends MPJLambdaWrapper<?>> extends IExt<Children> {

default <T, R> Children cccEq(SFunction<T, ?> c, Object val) {
getChildren().eq(c, val);
return getChildren();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,17 @@ void test6() {
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<UserTenantDO> wrapper = new MPJQueryWrapper<UserTenantDO>()
.setAlias("tt")
.selectAll(UserTenantDO.class,"tt")
.le("tt.id ", 10);
System.out.println(wrapper.getAlias());
List<UserTenantDO> userDO = userTenantMapper.selectJoinList(UserTenantDO.class, wrapper.lambda());
System.out.println(wrapper.getAlias());
System.out.println(userDO);
}

}
Original file line number Diff line number Diff line change
@@ -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<UserDO> wrapper = JoinWrappers.lambda(UserDO.class)
.selectAll()
.cccEq(UserDO::getId, 1);
wrapper.list();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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;
Expand All @@ -19,7 +19,7 @@
public class StringColumTest {

@Autowired
private UserMapper userMapper;
private UserCrudRepository userCrudRepository;

@BeforeEach
void setUp() {
Expand All @@ -33,7 +33,7 @@ void stringColum() {
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<UserDTO> l3 = userMapper.selectJoinList(UserDTO.class, new MPJLambdaWrapper<UserDO>()
List<UserDTO> l3 = userCrudRepository.selectJoinList(UserDTO.class, new MPJLambdaWrapper<UserDO>()
.select("(select id from `user` u where u.id = t.id) id")
.select("t.`name` as PName")
.select("t.`name` PName")
Expand Down
2 changes: 0 additions & 2 deletions plugin/mybatis-plus-join-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.4.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.30.2-GA</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down
1 change: 1 addition & 0 deletions plugin/mybatis-plus-join-solon-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<version>${revision}</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>${revision}</version>

<artifactId>mybatis-plus-join-solon-plugin</artifactId>

Expand Down
Loading

0 comments on commit eb3cecf

Please sign in to comment.