Skip to content

Commit

Permalink
调整依赖,将mybatis-plus-boot-starter依赖调整为provided,此外全部依赖不向下传递;
Browse files Browse the repository at this point in the history
  • Loading branch information
huangchengxing committed Feb 18, 2022
1 parent 5b626e4 commit b5c0bfa
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 82 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@

## 二、快速开始

1. 引入 mybatis-plus-join 依赖:
1. 引入 mybatis-plus-boot-starter 与 mybatis-plus-join 依赖:

~~~xml
<dependency>
<groupId>top.xiajibagao</groupId>
<artifactId>mybatis-plus-join</artifactId>
<version>2.0.0</version>
<version>${version}</version>
</dependency>

<depeendency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</depeendency>
~~~

> **注意**:项目引入了 hutool、lombok、mybaits-plus-boot-starter依赖,若与项目的依赖版本冲突需要自行排除
> 本项目需要自行引入依赖 `mybatis-plus-boot-starter`,此外其他依赖皆不向下传递
2. 将动态返回值插件`DynamicResultInterceptor`注册到 `com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean` 中 ,

Expand Down
20 changes: 11 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>top.xiajibagao</groupId>
<artifactId>mybatis-plus-join</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<name>mybatis-plus-join</name>
<description>mybatis plus join extend</description>
<packaging>jar</packaging>
Expand All @@ -46,28 +46,25 @@

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Hutool 工具类 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${findbugs.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -76,26 +73,31 @@
<optional>true</optional>
</dependency>

<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.76</version>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -35,8 +35,8 @@ public interface ExtendBaseMapper<T> extends BaseMapper<T> {
* @author huangchengxing
* @date 2021/9/23 13:27
*/
@NotNull
default <K> List<T> selectBatchByKeys(Collection<K> keys, @NotNull SFunction<T, K> column) {
@Nonnull
default <K> List<T> selectBatchByKeys(Collection<K> keys, @Nonnull SFunction<T, K> column) {
return CollUtil.isEmpty(keys) ?
new ArrayList<>() : selectList(wrapper().in(column, keys));
}
Expand All @@ -49,7 +49,7 @@ default <K> List<T> selectBatchByKeys(Collection<K> keys, @NotNull SFunction<T,
* @author huangchengxing
* @date 2021/9/23 13:27
*/
@NotNull
@Nonnull
default List<T> deleteBatchByIds(Collection<Integer> ids) {
return CollUtil.isEmpty(ids) ?
new ArrayList<>() : deleteBatchByIds(ids);
Expand All @@ -66,8 +66,8 @@ default List<T> deleteBatchByIds(Collection<Integer> ids) {
* @author huangchengxing
* @date 2021/9/23 13:27
*/
@NotNull
default <K> List<T> selectSomeColumnsBatchByKeys(Collection<K> keys, @NotNull SFunction<T, K> column, SFunction<T, ?>... selectColumns) {
@Nonnull
default <K> List<T> selectSomeColumnsBatchByKeys(Collection<K> keys, @Nonnull SFunction<T, K> column, SFunction<T, ?>... selectColumns) {
return CollUtil.isEmpty(keys) || ArrayUtil.isEmpty(selectColumns) ?
new ArrayList<>() : selectList(wrapper().select(selectColumns).in(column, keys));
}
Expand All @@ -84,11 +84,11 @@ default <K> List<T> selectSomeColumnsBatchByKeys(Collection<K> keys, @NotNull SF
* @author huangchengxing
* @date 2021/9/23 13:48
*/
@NotNull
@Nonnull
default <E, K> List<T> selectBatchByKeys(
Collection<E> entities,
@NotNull Function<E, K> keyGenerator,
@NotNull SFunction<T, K> column) {
@Nonnull Function<E, K> keyGenerator,
@Nonnull SFunction<T, K> column) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
Expand All @@ -107,8 +107,8 @@ default <E, K> List<T> selectBatchByKeys(
* @author huangchengxing
* @date 2021/9/23 13:27
*/
@NotNull
default <K> List<T> selectByKey(@NotNull K key, @NotNull SFunction<T, K> column) {
@Nonnull
default <K> List<T> selectByKey(@Nonnull K key, @Nonnull SFunction<T, K> column) {
return selectList(wrapper().eq(column, key));
}

Expand All @@ -123,8 +123,8 @@ default <K> List<T> selectByKey(@NotNull K key, @NotNull SFunction<T, K> column)
* @author huangchengxing
* @date 2021/9/23 13:27
*/
@NotNull
default <K> List<T> selectSomeColumnsByKey(@NotNull K key, @NotNull SFunction<T, K> column, @NotNull SFunction<T, ?>... selectColumns) {
@Nonnull
default <K> List<T> selectSomeColumnsByKey(@Nonnull K key, @Nonnull SFunction<T, K> column, @Nonnull SFunction<T, ?>... selectColumns) {
return selectList(wrapper().select(selectColumns).eq(column, key));
}

Expand All @@ -140,7 +140,7 @@ default <K> List<T> selectSomeColumnsByKey(@NotNull K key, @NotNull SFunction<T,
* @date 2021/9/29 9:26
*/
@Nullable
default <K> T selectOneByKey(@NotNull K key, @NotNull SFunction<T, K> column) {
default <K> T selectOneByKey(@Nonnull K key, @Nonnull SFunction<T, K> column) {
List<T> results = selectList(wrapper().eq(column, key));
Assert.isFalse(results.size() > 1, "期望查询1数据,但实际返回{}条", results.size());
return CollUtil.getFirst(results);
Expand All @@ -159,7 +159,7 @@ default <K> T selectOneByKey(@NotNull K key, @NotNull SFunction<T, K> column) {
* @date 2021/9/29 9:26
*/
@Nullable
default <K> T selectOneSomeColumnsByKey(@NotNull K key, @NotNull SFunction<T, K> column, @NotNull SFunction<T, ?>... selectColumns) {
default <K> T selectOneSomeColumnsByKey(@Nonnull K key, @Nonnull SFunction<T, K> column, @Nonnull SFunction<T, ?>... selectColumns) {
List<T> results = selectList(wrapper().select(selectColumns).eq(column, key));
Assert.isFalse(results.size() > 1, "期望查询1数据,但实际返回{}条", results.size());
return CollUtil.getFirst(results);
Expand All @@ -175,7 +175,7 @@ default <K> T selectOneSomeColumnsByKey(@NotNull K key, @NotNull SFunction<T, K>
* @author huangchengxing
* @date 2021/9/29 9:26
*/
default <K> int countByKey(@NotNull K key, @NotNull SFunction<T, K> column) {
default <K> int countByKey(@Nonnull K key, @Nonnull SFunction<T, K> column) {
return selectCount(wrapper().eq(column, key));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import org.apache.ibatis.reflection.property.PropertyNamer;

import javax.validation.constraints.NotNull;
import javax.annotation.Nonnull;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -30,7 +30,7 @@ private ColumnUtils() {
* @author huangchengxing
* @date 2021/12/29 18:21
*/
public static <T, R> String getColumnName(@NotNull SFunction<T, R> column) {
public static <T, R> String getColumnName(@Nonnull SFunction<T, R> column) {
return PROPERTY_COLUMN_NAME_CACHE.computeIfAbsent(
LambdaUtils.resolve(column).getImplMethodName(),
methodName -> StringUtils.camelToUnderline(PropertyNamer.methodToProperty(methodName))
Expand All @@ -45,7 +45,7 @@ public static <T, R> String getColumnName(@NotNull SFunction<T, R> column) {
* @author huangchengxing
* @date 2021/12/29 18:21
*/
public static <T, R> String getPropertyName(@NotNull SFunction<T, R> column) {
public static <T, R> String getPropertyName(@Nonnull SFunction<T, R> column) {
return PropertyNamer.methodToProperty(
LambdaUtils.resolve(column).getImplMethodName()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import top.xiajibagao.mybatis.plus.join.constants.ExtendConstants;
import top.xiajibagao.mybatis.plus.join.wrapper.JoinWrapper;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -65,7 +65,7 @@ public static String space(@Nullable ISqlSegment... targets) {
* @author huangchengxing
* @date 2022/2/7 11:23
*/
public static String concatAs(@NotNull String columnName, @NotNull String alisaName) {
public static String concatAs(@Nonnull String columnName, @Nonnull String alisaName) {
return CharSequenceUtil.isNotBlank(alisaName) ? space(columnName, AS, alisaName) : columnName;
}

Expand All @@ -90,7 +90,7 @@ public static String concatBrackets(@Nullable String target) {
* @author huangchengxing
* @date 2022/2/7 13:32
*/
public static String concatSegment(@Nullable String delimiter, @NotNull Collection<? extends ISqlSegment> segments) {
public static String concatSegment(@Nullable String delimiter, @Nonnull Collection<? extends ISqlSegment> segments) {
return segments.stream()
.map(ISqlSegment::getSqlSegment)
.collect(Collectors.joining(CharSequenceUtil.nullToEmpty(delimiter)));
Expand All @@ -104,7 +104,7 @@ public static String concatSegment(@Nullable String delimiter, @NotNull Collecti
* @author huangchengxing
* @date 2022/2/7 13:32
*/
public static String concatSegment(@NotNull Collection<? extends ISqlSegment> segments) {
public static String concatSegment(@Nonnull Collection<? extends ISqlSegment> segments) {
return concatSegment(null, segments);
}

Expand All @@ -116,7 +116,7 @@ public static String concatSegment(@NotNull Collection<? extends ISqlSegment> se
* @author huangchengxing
* @date 2022/2/9 14:11
*/
public static <W extends JoinWrapper<?, ?>> String wrapperToSql(@NotNull W wrapper) {
public static <W extends JoinWrapper<?, ?>> String wrapperToSql(@Nonnull W wrapper) {
return space(
SELECT, wrapper.getSqlSelect(),
FROM, space(wrapper.getTable(), wrapper.getAlisa()), NEWLINE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.apache.ibatis.type.UnknownTypeHandler;

import javax.validation.constraints.NotNull;
import javax.annotation.Nonnull;

/**
* 解析对象,将其转为{@link ResultMap}与{@link TableInfo},并将对象相关数据添加到{@link LambdaUtils}缓存中
Expand Down Expand Up @@ -48,7 +48,7 @@ public class StatementResultParser<T> {
* @author huangchengxing
* @date 2021/12/28 17:05
*/
public static <T> StatementResultParser<T> parse(@NotNull Configuration conf, @NotNull Class<T> targetClass) {
public static <T> StatementResultParser<T> parse(@Nonnull Configuration conf, @Nonnull Class<T> targetClass) {
return new StatementResultParser<>(conf, targetClass).parse(
"additional_info_" + targetClass.getName()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import top.xiajibagao.mybatis.plus.join.wrapper.column.TableColumn;
import top.xiajibagao.mybatis.plus.join.wrapper.interfaces.*;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -78,7 +78,7 @@ public abstract class AbstractDynamicResultWrapper<T, R, C extends AbstractDynam
* @author huangchengxing
* @date 2022/2/9 15:04
*/
protected AbstractDynamicResultWrapper(@NotNull Class<T> targetClass, @NotNull Class<R> resultClass, boolean isLogic) {
protected AbstractDynamicResultWrapper(@Nonnull Class<T> targetClass, @Nonnull Class<R> resultClass, boolean isLogic) {
this.targetClass = targetClass;
this.resultClass = resultClass;
// 临时的逻辑表没有对应实体信息
Expand Down Expand Up @@ -133,7 +133,7 @@ public C selectAll() {
* @date 2022/2/9 16:23
*/
@Override
public C select(@NotNull ColumnSegment column) {
public C select(@Nonnull ColumnSegment column) {
selectColumns.add(column);
return typedThis;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import top.xiajibagao.mybatis.plus.join.constants.JoinType;
import top.xiajibagao.mybatis.plus.join.helper.SqlUtils;

import javax.validation.constraints.NotNull;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -58,15 +58,15 @@ public boolean hasJoin() {
* @author huangchengxing
* @date 2022/2/9 15:37
*/
public static <T, R> JoinWrapper<T, R> create(@NotNull Class<T> targetClass, @NotNull Class<R> resultClass) {
public static <T, R> JoinWrapper<T, R> create(@Nonnull Class<T> targetClass, @Nonnull Class<R> resultClass) {
JoinWrapper<T, R> result = new JoinWrapper<>(targetClass, resultClass, false);
result.initNeed();
result.setAlisaByJoinSeq();
result.initLogicDelete();
return result;
}

protected JoinWrapper(@NotNull Class<T> targetClass, @NotNull Class<R> resultClass, boolean isLogic) {
protected JoinWrapper(@Nonnull Class<T> targetClass, @Nonnull Class<R> resultClass, boolean isLogic) {
super(targetClass, resultClass, isLogic);
}

Expand Down Expand Up @@ -363,7 +363,7 @@ public static class JoinTable<T, J, R> extends JoinWrapper<J, R> {
private final JoinWrapper<T, R> source;
private final MergeSegments joinCondition;

public JoinTable(JoinType joinType, @NotNull Class<J> targetClass, JoinWrapper<T, R> source, boolean isLogic) {
public JoinTable(JoinType joinType, @Nonnull Class<J> targetClass, JoinWrapper<T, R> source, boolean isLogic) {
super(targetClass, source.getResultClass(), isLogic);

this.joinType = joinType;
Expand Down
Loading

0 comments on commit b5c0bfa

Please sign in to comment.