mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
支持字段映射升级 mybatis plus -> 3.4.3.2
This commit is contained in:
parent
2659497f0a
commit
c6a861d9f0
@ -2,9 +2,11 @@ package com.github.yulichang.injector;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||||
|
import com.baomidou.mybatisplus.core.injector.methods.*;
|
||||||
import com.baomidou.mybatisplus.core.mapper.Mapper;
|
import com.baomidou.mybatisplus.core.mapper.Mapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.MPJTableAliasHelper;
|
import com.baomidou.mybatisplus.core.metadata.MPJTableAliasHelper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.MPJTableInfoHelper;
|
import com.baomidou.mybatisplus.core.metadata.MPJTableInfoHelper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ClassUtils;
|
import com.baomidou.mybatisplus.core.toolkit.ClassUtils;
|
||||||
import com.github.yulichang.method.*;
|
import com.github.yulichang.method.*;
|
||||||
@ -12,8 +14,12 @@ import org.apache.ibatis.builder.MapperBuilderAssistant;
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.core.GenericTypeResolver;
|
import org.springframework.core.GenericTypeResolver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL 注入器
|
* SQL 注入器
|
||||||
@ -24,9 +30,43 @@ import java.util.Objects;
|
|||||||
@ConditionalOnMissingBean(DefaultSqlInjector.class)
|
@ConditionalOnMissingBean(DefaultSqlInjector.class)
|
||||||
public class MPJSqlInjector extends DefaultSqlInjector {
|
public class MPJSqlInjector extends DefaultSqlInjector {
|
||||||
|
|
||||||
@Override
|
@SuppressWarnings("unused")
|
||||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
|
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
|
||||||
List<AbstractMethod> list = super.getMethodList(mapperClass);
|
List<AbstractMethod> list = Stream.of(
|
||||||
|
new Insert(),
|
||||||
|
new Delete(),
|
||||||
|
new DeleteByMap(),
|
||||||
|
new DeleteById(),
|
||||||
|
new DeleteBatchByIds(),
|
||||||
|
new Update(),
|
||||||
|
new UpdateById(),
|
||||||
|
new SelectById(),
|
||||||
|
new SelectBatchByIds(),
|
||||||
|
new SelectByMap(),
|
||||||
|
new SelectOne(),
|
||||||
|
new SelectCount(),
|
||||||
|
new SelectMaps(),
|
||||||
|
new SelectMapsPage(),
|
||||||
|
new SelectObjs(),
|
||||||
|
new SelectList(),
|
||||||
|
new SelectPage()
|
||||||
|
).collect(toList());
|
||||||
|
list.addAll(getJoinMethod());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mybatis plus 3.4.3.2
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
||||||
|
List<AbstractMethod> list = super.getMethodList(mapperClass, tableInfo);
|
||||||
|
list.addAll(getJoinMethod());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AbstractMethod> getJoinMethod() {
|
||||||
|
List<AbstractMethod> list = new ArrayList<>();
|
||||||
list.add(new SelectJoinCount());
|
list.add(new SelectJoinCount());
|
||||||
list.add(new SelectJoinOne());
|
list.add(new SelectJoinOne());
|
||||||
list.add(new SelectJoinList());
|
list.add(new SelectJoinList());
|
||||||
|
@ -138,7 +138,7 @@ public class MPJLambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, MPJLambda
|
|||||||
public final MPJLambdaQueryWrapper<T> selectIgnore(SFunction<T, ?>... columns) {
|
public final MPJLambdaQueryWrapper<T> selectIgnore(SFunction<T, ?>... columns) {
|
||||||
if (ArrayUtils.isNotEmpty(columns)) {
|
if (ArrayUtils.isNotEmpty(columns)) {
|
||||||
for (SFunction<T, ?> s : columns) {
|
for (SFunction<T, ?> s : columns) {
|
||||||
ignoreColumns.add(this.alias + StringPool.DOT + getColumnCache(s).getColumn());
|
ignoreColumns.add(this.alias + StringPool.DOT + super.columnToString(s, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
|
@ -182,16 +182,4 @@ public final class ReflectionKit {
|
|||||||
public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) {
|
public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) {
|
||||||
return (clazz.isPrimitive() && clazz != void.class ? PRIMITIVE_TYPE_TO_WRAPPER_MAP.get(clazz) : clazz);
|
return (clazz.isPrimitive() && clazz != void.class ? PRIMITIVE_TYPE_TO_WRAPPER_MAP.get(clazz) : clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置可访问对象的可访问权限为 true
|
|
||||||
*
|
|
||||||
* @param object 可访问的对象
|
|
||||||
* @param <T> 类型
|
|
||||||
* @return 返回设置后的对象
|
|
||||||
*/
|
|
||||||
public static <T extends AccessibleObject> T setAccessible(T object) {
|
|
||||||
return AccessController.doPrivileged(new SetAccessibleAction<>(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user