This commit is contained in:
yulichang 2024-11-05 12:24:09 +08:00
parent d7f7f19fac
commit 6abb21a5ee
7 changed files with 4 additions and 218 deletions

View File

@ -32,7 +32,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Publish to Apache Maven Central - name: Publish to Apache Maven Central
run: mvn com.github.yulichang:pom-maven-plugin:1.1:pom -Prelease && mvn clean deploy -Prelease run: mvn com.github.yulichang:pom-maven-plugin:1.3:pom -Dprofile=release && mvn clean deploy
env: env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}

View File

@ -32,7 +32,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Publish to Apache Maven Central - name: Publish to Apache Maven Central
run: mvn com.github.yulichang:pom-maven-plugin:1.0:pom -Psnapshot && mvn deploy -Prelease -Psnapshot run: mvn com.github.yulichang:pom-maven-plugin:1.3:pom -Dprofile=snapshot && mvn clean deploy
env: env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}

View File

@ -114,17 +114,7 @@ WHERE (
AND t.id > ?) AND t.id > ?)
``` ```
MPJLambdaWrapper其他功能 # <a href="https://mybatis-plus-join.github.io" target="_blank">完整使用文档 wiki</a>
* <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" target="_blank">其他全部功能请参考使用文档</a>
# <a href="https://mybatis-plus-join.github.io" target="_blank">使用文档 wiki</a>
# 用爱发电 # 用爱发电

View File

@ -114,16 +114,7 @@ WHERE (
AND t.id > ?) AND t.id > ?)
``` ```
# <a href="https://mybatis-plus-join.github.io" target="_blank">完整使用文档 wiki</a>
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" 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"> <a href="https://mybatis-plus-join.github.io/pages/quickstart/support.html" target="_blank">
<img alt="支持一下mybatis-plus-join" src="https://mybatis-plus-join.github.io/support.png"> <img alt="支持一下mybatis-plus-join" src="https://mybatis-plus-join.github.io/support.png">

View File

@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -194,21 +193,6 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
return subInstance(clazz, ConfigProperties.subQueryAlias); return subInstance(clazz, ConfigProperties.subQueryAlias);
} }
/**
* 转为子类方便自定义继承扩展
*/
public <C extends Children> C toChildren(Ref<C> children) {
return (C) this;
}
/**
* 转为子类方便自定义继承扩展
* 需要子类自定义字段
*/
public <C extends Children> C toChildren(Supplier<C> s) {
return (C) this;
}
/** /**
* 开启检查 SQL 注入 * 开启检查 SQL 注入
*/ */

View File

@ -1,64 +0,0 @@
package com.github.yulichang.test.join.unit;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.github.yulichang.test.join.entity.UserDO;
import com.github.yulichang.test.join.mapper.UserMapper;
import com.github.yulichang.test.util.Reset;
import com.github.yulichang.test.util.ThreadLocalUtils;
import com.github.yulichang.toolkit.Ref;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
import java.util.Objects;
@SpringBootTest
public class CustomWrapperTest {
@Autowired
private UserMapper userMapper;
@BeforeEach
void setUp() {
Reset.reset();
}
//自定义wrapper扩展
public static class CWrapper<T> extends MPJLambdaWrapper<T> {
public static <T> CWrapper<T> toCWrapper() {
return null;
}
@Override
public <X> CWrapper<T> eqIfExists(SFunction<X, ?> column, Object val) {
super.eq(Objects.nonNull(val), column, val);
return this;
}
}
@Test
void testWrapperCustomer() {
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 = ?)");
CWrapper<UserDO> wrapper = new CWrapper<UserDO>()
.selectAll(UserDO.class)
// .toChildren(new Ref<CWrapper<UserDO>>())
.toChildren(CWrapper::toCWrapper)
.eqIfExists(UserDO::getId, 1);
List<UserDO> dos = userMapper.selectList(wrapper);
dos.forEach(System.out::println);
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");
CWrapper<UserDO> wrapper1 = new CWrapper<UserDO>()
.selectAll(UserDO.class)
.toChildren(new Ref<CWrapper<UserDO>>())
// .toChildren(CWrapper::toCWrapper)
.eqIfExists(UserDO::getId, null);
List<UserDO> dos1 = userMapper.selectList(wrapper1);
dos1.forEach(System.out::println);
}
}

115
pom.xml
View File

@ -51,7 +51,6 @@
<jdkVersion.test>17</jdkVersion.test> <jdkVersion.test>17</jdkVersion.test>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<github.global.server>github</github.global.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding> <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
@ -70,120 +69,6 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<profiles>
<profile>
<id>snapshot</id>
<build>
<plugins>
<plugin>
<groupId>com.github.yulichang</groupId>
<artifactId>pom-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<args>
<arg>
<xpath>project/properties/revision</xpath>
<format>%s-SNAPSHOT</format>
</arg>
</args>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.github.yulichang</groupId>
<artifactId>pom-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<args>
<arg>
<type>remove</type>
<project>mybatis-plus-join-root</project>
<xpath>project/modules/module</xpath>
<contentMatches>\S*-test</contentMatches>
</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<serverId>maven</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalJOptions>
<additionalJOption>-Xdoclint:none</additionalJOption>
</additionalJOptions>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>maven</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>maven</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>