diff --git a/README.md b/README.md index 5c1c52a..d340e2b 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ class test { List list = userMapper.selectJoinList(UserDTO.class, wrapper); //分页查询 (需要启用 mybatis plus 分页插件) - List listPage = userMapper.selectJoinPage(new Page<>(2, 10), UserDTO.class, wrapper); + Page listPage = userMapper.selectJoinPage(new Page<>(2, 10), UserDTO.class, wrapper); } } ``` @@ -165,7 +165,7 @@ class test { List list = userMapper.selectJoinList(UserDTO.class, wrapper); //分页查询 (需要启用 mybatis plus 分页插件) - List listPage = userMapper.selectJoinPage(new Page<>(1, 10), UserDTO.class, wrapper); + Page listPage = userMapper.selectJoinPage(new Page<>(1, 10), UserDTO.class, wrapper); } } ``` diff --git a/mybatis-plus-join-boot-starter/src/main/java/com/github/yulichang/autoconfigure/MybatisPlusJoinAutoConfiguration.java b/mybatis-plus-join-boot-starter/src/main/java/com/github/yulichang/autoconfigure/MybatisPlusJoinAutoConfiguration.java index bbb011b..ab495cb 100644 --- a/mybatis-plus-join-boot-starter/src/main/java/com/github/yulichang/autoconfigure/MybatisPlusJoinAutoConfiguration.java +++ b/mybatis-plus-join-boot-starter/src/main/java/com/github/yulichang/autoconfigure/MybatisPlusJoinAutoConfiguration.java @@ -39,7 +39,7 @@ import java.util.List; * @author yulichang * @since 1.3.7 */ -@SuppressWarnings("unused") +@SuppressWarnings("ALL") @Configuration(proxyBeanMethods = false) @ConditionalOnClass({SqlSessionFactory.class, SqlSessionFactoryBean.class}) @ConditionalOnSingleCandidate(DataSource.class) @@ -83,6 +83,7 @@ public class MybatisPlusJoinAutoConfiguration { @Order(Ordered.HIGHEST_PRECEDENCE) @ConditionalOnMissingBean({DefaultSqlInjector.class, AbstractSqlInjector.class, ISqlInjector.class}) public MPJSqlInjector mpjSqlInjector() { + logger.info("MPJSqlInjector init"); return new MPJSqlInjector(); } @@ -91,7 +92,6 @@ public class MybatisPlusJoinAutoConfiguration { */ @Bean @Order(Ordered.HIGHEST_PRECEDENCE) - @SuppressWarnings("InstantiationOfUtilityClass") public SpringContentUtils springContentUtils(SpringContext springContext) { return new SpringContentUtils(springContext); } @@ -119,7 +119,6 @@ public class MybatisPlusJoinAutoConfiguration { } @Override - @SuppressWarnings("NullableProblems") public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } diff --git a/mybatis-plus-join-core/pom.xml b/mybatis-plus-join-core/pom.xml index ab0d912..288cd4f 100644 --- a/mybatis-plus-join-core/pom.xml +++ b/mybatis-plus-join-core/pom.xml @@ -61,12 +61,6 @@ 1.18.24 provided - - org.slf4j - slf4j-api - provided - 2.0.4 - org.springframework spring-aop diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java index 6789e38..d4807d3 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/interceptor/MPJInterceptor.java @@ -240,9 +240,9 @@ public class MPJInterceptor implements Interceptor { Field field = ofTypeField.get(r.getProperty()); if (columnSet.contains(columnName)) { columnName = getColumn(columnSet, columnName); - label = new SelectLabel(r.getSelectNormal(), mybatisLabel.getOfType(), field, columnName); + label = new SelectLabel(r.getSelectNormal(), mybatisLabel.getIndex(), mybatisLabel.getOfType(), field, columnName); } else { - label = new SelectLabel(r.getSelectNormal(), mybatisLabel.getOfType(), field); + label = new SelectLabel(r.getSelectNormal(), mybatisLabel.getIndex(), mybatisLabel.getOfType(), field); } columnList.add(label); ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), r.getProperty(), columnName, r.getJavaType()); diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/LogicInfoUtils.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/LogicInfoUtils.java index bfd1dce..abf0838 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/LogicInfoUtils.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/LogicInfoUtils.java @@ -18,15 +18,20 @@ import java.util.concurrent.ConcurrentHashMap; */ public class LogicInfoUtils implements Constants { - private static final Map, String> LOGIC_CACHE = new ConcurrentHashMap<>(); + private static final Map, Map> LOGIC_CACHE = new ConcurrentHashMap<>(); - @SuppressWarnings("ConstantConditions") - public static String getLogicInfo(int tableIndex, Class clazz) { - String logicStr = LOGIC_CACHE.get(clazz); - if (Objects.nonNull(logicStr)) { - return logicStr; + public static String getLogicInfo(String tableIndex, Class clazz) { + Map absent = LOGIC_CACHE.get(clazz); + if (absent == null) { + absent = new ConcurrentHashMap<>(); + LOGIC_CACHE.put(clazz, absent); } + return absent.computeIfAbsent(tableIndex, key -> getLogicStr(key, clazz)); + } + + private static String getLogicStr(String tableIndex, Class clazz) { + String logicStr; TableInfo tableInfo = TableInfoHelper.getTableInfo(clazz); Assert.notNull(tableInfo, "%s 不是数据库实体或没有注册到mybatis plus中", clazz.getName()); if (tableInfo.isWithLogicDelete() && Objects.nonNull(tableInfo.getLogicDeleteFieldInfo())) { @@ -39,7 +44,6 @@ public class LogicInfoUtils implements Constants { } else { logicStr = StringPool.EMPTY; } - LOGIC_CACHE.put(clazz, logicStr); return logicStr; } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ColumnCache.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ColumnCache.java index 8330bae..22f8a4b 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ColumnCache.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ColumnCache.java @@ -3,7 +3,7 @@ package com.github.yulichang.toolkit.support; import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; import com.baomidou.mybatisplus.core.toolkit.Assert; -import com.github.yulichang.wrapper.segments.SelectNormal; +import com.github.yulichang.wrapper.segments.SelectCache; import java.util.ArrayList; import java.util.List; @@ -20,24 +20,24 @@ import java.util.stream.Collectors; */ public class ColumnCache { - private static final Map, List> LIST_CACHE = new ConcurrentHashMap<>(); + private static final Map, List> LIST_CACHE = new ConcurrentHashMap<>(); - private static final Map, Map> MAP_CACHE = new ConcurrentHashMap<>(); + private static final Map, Map> MAP_CACHE = new ConcurrentHashMap<>(); - public static List getListField(Class clazz) { + public static List getListField(Class clazz) { return LIST_CACHE.computeIfAbsent(clazz, c -> { TableInfo tableInfo = TableInfoHelper.getTableInfo(clazz); Assert.notNull(tableInfo, "table not find by class <%s>", c.getSimpleName()); - List list = new ArrayList<>(); + List list = new ArrayList<>(); if (tableInfo.havePK()) { - list.add(new SelectNormal(clazz, true, tableInfo.getKeyColumn(), tableInfo.getKeyType(), tableInfo.getKeyProperty(), null)); + list.add(new SelectCache(clazz, true, tableInfo.getKeyColumn(), tableInfo.getKeyType(), tableInfo.getKeyProperty(), null)); } - list.addAll(tableInfo.getFieldList().stream().map(f -> new SelectNormal(clazz, false, f.getColumn(), f.getPropertyType(), f.getProperty(), f)).collect(Collectors.toList())); + list.addAll(tableInfo.getFieldList().stream().map(f -> new SelectCache(clazz, false, f.getColumn(), f.getPropertyType(), f.getProperty(), f)).collect(Collectors.toList())); return list; }); } - public static Map getMapField(Class clazz) { - return MAP_CACHE.computeIfAbsent(clazz, c -> getListField(c).stream().collect(Collectors.toMap(SelectNormal::getColumProperty, Function.identity(), (i, j) -> j))); + public static Map getMapField(Class clazz) { + return MAP_CACHE.computeIfAbsent(clazz, c -> getListField(c).stream().collect(Collectors.toMap(SelectCache::getColumProperty, Function.identity(), (i, j) -> j))); } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ReflectLambdaMeta.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ReflectLambdaMeta.java index 11796f7..a37c03c 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ReflectLambdaMeta.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/support/ReflectLambdaMeta.java @@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.github.yulichang.toolkit.ClassUtils; import com.github.yulichang.toolkit.ReflectionKit; -import lombok.extern.slf4j.Slf4j; import java.lang.invoke.SerializedLambda; import java.lang.reflect.Field; @@ -28,7 +27,6 @@ import java.lang.reflect.Field; /** * Created by hcl at 2021/5/14 */ -@Slf4j public class ReflectLambdaMeta implements LambdaMeta { private static final Field FIELD_CAPTURING_CLASS; @@ -39,7 +37,6 @@ public class ReflectLambdaMeta implements LambdaMeta { fieldCapturingClass = ReflectionKit.setAccessible(aClass.getDeclaredField("capturingClass")); } catch (Throwable e) { // 解决高版本 jdk 的问题 gitee: https://gitee.com/baomidou/mybatis-plus/issues/I4A7I5 - log.warn(e.getMessage()); fieldCapturingClass = null; } FIELD_CAPTURING_CLASS = fieldCapturingClass; diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java index 2956e3f..c508990 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/MPJAbstractLambdaWrapper.java @@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.github.yulichang.toolkit.Constant; import com.github.yulichang.toolkit.LambdaUtils; import com.github.yulichang.toolkit.support.ColumnCache; -import com.github.yulichang.wrapper.segments.SelectNormal; +import com.github.yulichang.wrapper.segments.SelectCache; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; +import java.util.stream.Stream; import static java.util.stream.Collectors.joining; @@ -25,7 +27,13 @@ public abstract class MPJAbstractLambdaWrapper, Integer> subTable = new HashMap<>(); + protected TableList tableList = new TableList(); + /** + * 表别名 + */ + @Getter + protected String index; + @Override protected String columnToString(X column, boolean isJoin) { @@ -44,35 +52,87 @@ public abstract class MPJAbstractLambdaWrapper fn) { + protected SelectCache getCache(SFunction fn) { Class aClass = LambdaUtils.getEntityClass(fn); - Map cacheMap = ColumnCache.getMapField(aClass); + Map cacheMap = ColumnCache.getMapField(aClass); return cacheMap.get(LambdaUtils.getName(fn)); } protected String getDefault(Class clazz, boolean isJoin) { - Integer index = subTable.get(clazz); - if (Objects.nonNull(index)) { + Table table = tableList.get(clazz, index); + if (Objects.nonNull(table.getIndex())) { if (getEntityClass() == null) { - return index.toString(); + return table.getIndex(); } if (isJoin && joinClass == getEntityClass()) { return StringPool.EMPTY; } - return index.toString(); + return table.getIndex(); } return StringPool.EMPTY; } protected String getDefaultSelect(Class clazz, boolean myself) { - Integer index = subTable.get(clazz); - if (Objects.nonNull(index)) { + Table table = tableList.get(clazz, index); + if (Objects.nonNull(table.getIndex())) { if (myself) { return StringPool.EMPTY; } - return index.toString(); + return table.getIndex(); } return StringPool.EMPTY; } + public static class TableList { + + private static final Table DEFAULT_TABLE = new Table(null, null); + + private final List list = new ArrayList<>(); + + public void add(Class clazz, String index) { + this.list.add(new Table(clazz, index)); + } + + private Table get(Class clazz) { + for (Table t : list) { + if (clazz == t.clazz) { + return t; + } + } + return DEFAULT_TABLE; + } + + public Table get(Class clazz, String index) { + if (Objects.isNull(index)) { + return get(clazz); + } + for (Table t : list) { + if (clazz == t.clazz && Objects.equals(index, t.getIndex())) { + return t; + } + } + return DEFAULT_TABLE; + } + + public Stream
stream() { + return list.stream(); + } + + public void clear() { + list.clear(); + } + + public boolean isEmpty() { + return list.isEmpty(); + } + } + + @Data + @EqualsAndHashCode + @AllArgsConstructor + public static class Table { + private Class clazz; + + private String index; + } } 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 e48a972..5832ef4 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,34 +2,32 @@ 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.metadata.TableFieldInfo; -import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; -import com.baomidou.mybatisplus.core.toolkit.*; +import com.baomidou.mybatisplus.core.toolkit.ArrayUtils; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.github.yulichang.config.ConfigProperties; +import com.github.yulichang.toolkit.Constant; import com.github.yulichang.toolkit.LambdaUtils; -import com.github.yulichang.toolkit.*; +import com.github.yulichang.toolkit.LogicInfoUtils; +import com.github.yulichang.toolkit.MPJWrappers; import com.github.yulichang.toolkit.support.ColumnCache; -import com.github.yulichang.wrapper.enums.BaseFuncEnum; -import com.github.yulichang.wrapper.interfaces.LambdaJoin; import com.github.yulichang.wrapper.interfaces.Query; +import com.github.yulichang.wrapper.interfaces.QueryJoin; +import com.github.yulichang.wrapper.interfaces.QueryLabel; import com.github.yulichang.wrapper.interfaces.on.OnFunction; -import com.github.yulichang.wrapper.resultmap.MFunc; import com.github.yulichang.wrapper.resultmap.MybatisLabel; import com.github.yulichang.wrapper.segments.Select; -import com.github.yulichang.wrapper.segments.SelectAlias; -import com.github.yulichang.wrapper.segments.SelectFunc; +import com.github.yulichang.wrapper.segments.SelectCache; import com.github.yulichang.wrapper.segments.SelectNormal; import lombok.Getter; -import java.lang.reflect.Field; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Predicate; import java.util.stream.Collectors; /** @@ -39,9 +37,9 @@ import java.util.stream.Collectors; * @author yulichang * @see MPJWrappers */ -@SuppressWarnings({"unused", "unchecked"}) +@SuppressWarnings({"unused"}) public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper> - implements Query>, LambdaJoin, T> { + implements Query>, QueryJoin, T>, QueryLabel> { /** * 查询表 @@ -66,11 +64,6 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper extends MPJAbstractLambdaWrapper entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq, Map paramNameValuePairs, MergeSegments mergeSegments, SharedString lastSql, SharedString sqlComment, SharedString sqlFirst, - Map, Integer> subTable, String keyWord, Class joinClass) { + TableList tableList, String keyWord, Class joinClass) { super.setEntity(entity); super.setEntityClass(entityClass); this.paramNameSeq = paramNameSeq; @@ -121,7 +114,7 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper extends MPJAbstractLambdaWrapper getSelectColum() { + return this.selectColumns; + } + + @Override + public void addLabel(MybatisLabel label) { + this.resultMap = true; + this.resultMapMybatisLabel.add(label); + } + + @Override + public MPJLambdaWrapper getChildren() { + return typedThis; + } + + + /** + * 设置查询字段 + * + * @param columns 字段数组 + * @return children + */ @SafeVarargs - public final MPJLambdaWrapper select(SFunction... columns) { + public final MPJLambdaWrapper select(SFunction... columns) { if (ArrayUtils.isNotEmpty(columns)) { - for (SFunction s : columns) { - SelectNormal cache = getCache(s); - selectColumns.add(cache); + Class aClass = LambdaUtils.getEntityClass(columns[0]); + Map cacheMap = ColumnCache.getMapField(aClass); + for (SFunction s : columns) { + SelectCache cache = cacheMap.get(LambdaUtils.getName(s)); + getSelectColum().add(new SelectNormal(cache, index)); } } return typedThis; } - /** - * 一对多查询 调用此方法发必需要调用对应的 left join / right join ... 连表方法,否则会报错 - *

- * 举例 UserDO AddressDO 为一对多关系 UserDTO 为结果类 - *

-     *     MPJLambdaQueryWrapper wrapper = new MPJLambdaQueryWrapper();
-     *     wrapper.selectAll(UserDO.class)
-     *            .selectCollection(AddressDO.class, UserDTO::getAddressListDTO)
-     *            .leftJoin(AddressDO.class, ...... )
-     *            .eq(...)
-     *            ...
-     * 
-     * 会自动将 AddressDO类中相同属性的字段 以mybatis的方式映射到UserDTO.addressListDTO属性中
-     *
-     * @since 1.3.0
-     *
-     * @param child    连表数据库实体类
-     * @param dtoField 包装类对应的属性
-     * @param       包装类
-     * @param       对多数据库实体类
-     * @param       包装类集合泛型
-     * @param       包装类集合字段泛型
-     */
-    public > MPJLambdaWrapper selectCollection(Class child, SFunction dtoField) {
-        String dtoFieldName = LambdaUtils.getName(dtoField);
-        Class dtoClass = LambdaUtils.getEntityClass(dtoField);
-        Map fieldMap = MPJReflectionKit.getFieldMap(dtoClass);
-        Field field = fieldMap.get(dtoFieldName);
-        this.resultMap = true;
-        Class genericType = MPJReflectionKit.getGenericType(field);
-        MybatisLabel.Builder builder;
-        if (genericType == null || genericType.isAssignableFrom(child)) {
-            //找不到集合泛型 List List List , 直接查询数据库实体
-            builder = new MybatisLabel.Builder<>(dtoFieldName, child, field.getType());
-        } else {
-            Class ofType = (Class) genericType;
-            builder = new MybatisLabel.Builder<>(dtoFieldName, child, field.getType(), ofType, true);
-        }
-        this.resultMapMybatisLabel.add(builder.build());
-        return typedThis;
-    }
-
-    /**
-     * 一对多查询 调用此方法发必需要调用对应的 left join / right join ... 连表方法,否则会报错
-     * 

- * 举例 UserDO AddressDO 为一对多关系 UserDTO 为结果类 - *

-     *   MPJLambdaQueryWrapper wrapper = new MPJLambdaQueryWrapper();
-     *   wrapper.selectAll(UserDO.class)
-     *      .selectCollection(AddressDO.class, UserDTO::getAddressListDTO, map -> map
-     *           .id(AddressDO::getId, AddressDTO::getId)                 //如果属性名一致 可以传一个
-     *           .result(AddressDO::getUserId)                            //如果属性名一致 可以传一个
-     *           .result(AddressDO::getAddress, AddressDTO::getAddress))) //如果属性名一致 可以传一个
-     *      .leftJoin(AddressDO.class, ...... )
-     *      .eq(...)
-     *      ...
-     * 
-     *
-     * 会自动将 AddressDO类中指定的字段 以mybatis的方式映射到UserDTO.addressListDTO属性中
-     *
-     * @since 1.3.0
-     *
-     * @param child      连表数据库实体类
-     * @param dtoField   包装类对应的属性
-     * @param collection collection标签内容
-     * @param         包装类
-     * @param         对多数据库实体类
-     * @param         包装类集合泛型
-     * @param         包装类集合字段泛型
-     */
-    public > MPJLambdaWrapper
-    selectCollection(Class child, SFunction dtoField, MFunc> collection) {
-        String dtoFieldName = LambdaUtils.getName(dtoField);
-        Class dtoClass = LambdaUtils.getEntityClass(dtoField);
-        Field field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
-        this.resultMap = true;
-        //获取集合泛型
-        Class genericType = MPJReflectionKit.getGenericType(field);
-        Class ofType = (Class) genericType;
-        MybatisLabel.Builder builder = new MybatisLabel.Builder<>(dtoFieldName, child, field.getType(), ofType, false);
-        MybatisLabel.Builder czBuilder = collection.apply(builder);
-        this.customResult = czBuilder.hasCustom();
-        this.resultMapMybatisLabel.add(czBuilder.build());
-        return typedThis;
-    }
-
-    /**
-     * 对一查询 用法参考 selectCollection
-     *
-     * @since 1.3.0
-     */
-    public  MPJLambdaWrapper selectAssociation(Class child, SFunction dtoField) {
-        String dtoFieldName = LambdaUtils.getName(dtoField);
-        Class dtoClass = LambdaUtils.getEntityClass(dtoField);
-        Map fieldMap = MPJReflectionKit.getFieldMap(dtoClass);
-        Field field = fieldMap.get(dtoFieldName);
-        Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
-        this.resultMap = true;
-        MybatisLabel.Builder builder;
-        builder = new MybatisLabel.Builder<>(dtoFieldName, child, field.getType(), (Class) field.getType(), true);
-        this.resultMapMybatisLabel.add(builder.build());
-        return typedThis;
-    }
-
-    /**
-     * 对一查询 用法参考 selectCollection
-     *
-     * @since 1.3.0
-     */
-    public  MPJLambdaWrapper selectAssociation(Class child, SFunction dtoField,
-                                                           MFunc> collection) {
-        String dtoFieldName = LambdaUtils.getName(dtoField);
-        Class dtoClass = LambdaUtils.getEntityClass(dtoField);
-        Field field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
-        this.resultMap = true;
-        Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
-        MybatisLabel.Builder builder = new MybatisLabel.Builder<>(dtoFieldName, child, field.getType(), (Class) child, false);
-        MybatisLabel.Builder cfBuilder = collection.apply(builder);
-        this.customResult = cfBuilder.hasCustom();
-        this.resultMapMybatisLabel.add(cfBuilder.build());
-        return typedThis;
-    }
-
-
-    @Override
-    public  MPJLambdaWrapper select(Class entityClass, Predicate predicate) {
-        TableInfo info = TableInfoHelper.getTableInfo(entityClass);
-        Map cacheMap = ColumnCache.getMapField(entityClass);
-        info.getFieldList().stream().filter(predicate).collect(Collectors.toList()).forEach(
-                i -> selectColumns.add(cacheMap.get(i.getProperty())));
-        return typedThis;
-    }
-
-    @Override
-    public  MPJLambdaWrapper selectAsClass(Class source, Class tag) {
-        List normalList = ColumnCache.getListField(source);
-        Map fieldMap = MPJReflectionKit.getFieldMap(tag);
-        for (SelectNormal cache : normalList) {
-            if (fieldMap.containsKey(cache.getColumProperty())) {
-                selectColumns.add(cache);
-            }
-        }
-        return typedThis;
-    }
-
-    @Override
-    public  MPJLambdaWrapper selectAs(SFunction column, String alias) {
-        selectColumns.add(new SelectAlias(getCache(column), alias));
-        return typedThis;
-    }
-
-    public  MPJLambdaWrapper selectFunc(BaseFuncEnum funcEnum, SFunction column, String alias) {
-        selectColumns.add(new SelectFunc(getCache(column), alias, funcEnum));
-        return typedThis;
-    }
-
-    @Override
-    public MPJLambdaWrapper selectFunc(BaseFuncEnum funcEnum, Object column, String alias) {
-        selectColumns.add(new SelectFunc(alias, funcEnum, column.toString()));
-        return typedThis;
-    }
-
-    public final MPJLambdaWrapper selectAll(Class clazz) {
-        selectColumns.addAll(ColumnCache.getListField(clazz));
-        return typedThis;
-    }
-
     /**
      * 查询条件 SQL 片段
      */
@@ -341,7 +192,7 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper extends MPJAbstractLambdaWrapper instance(String keyWord, Class joinClass) {
         return new MPJLambdaWrapper<>(getEntity(), getEntityClass(), null, paramNameSeq, paramNameValuePairs,
                 new MergeSegments(), SharedString.emptyString(), SharedString.emptyString(), SharedString.emptyString(),
-                this.subTable, keyWord, joinClass);
+                this.tableList, keyWord, joinClass);
     }
 
     @Override
@@ -380,7 +231,7 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper extends MPJAbstractLambdaWrapper LogicInfoUtils.getLogicInfo(entry.getValue(),
-                    entry.getKey())).collect(Collectors.joining(StringPool.SPACE));
+            return tableList.stream().map(t -> LogicInfoUtils.getLogicInfo(t.getIndex(),
+                    t.getClazz())).collect(Collectors.joining(StringPool.SPACE));
         }
         return StringPool.EMPTY;
     }
@@ -437,7 +288,7 @@ public class MPJLambdaWrapper extends MPJAbstractLambdaWrapper MPJLambdaWrapper join(String keyWord, Class clazz, OnFunction function) {
         MPJLambdaWrapper apply = function.apply(instance(keyWord, clazz));
-        subTable.put(clazz, tableIndex);
+        tableList.add(clazz, String.valueOf(tableIndex));
         onWrappers.add(apply);
         tableIndex++;
         return typedThis;
diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java
index 63b1c55..94f9b8a 100644
--- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java
+++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/Query.java
@@ -1,13 +1,22 @@
 package com.github.yulichang.wrapper.interfaces;
 
 import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import com.github.yulichang.toolkit.LambdaUtils;
+import com.github.yulichang.toolkit.MPJReflectionKit;
+import com.github.yulichang.toolkit.support.ColumnCache;
 import com.github.yulichang.wrapper.enums.BaseFuncEnum;
 import com.github.yulichang.wrapper.enums.DefaultFuncEnum;
+import com.github.yulichang.wrapper.segments.*;
 
 import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.Map;
 import java.util.function.Predicate;
+import java.util.stream.Collectors;
 
 /**
  * 参考 {@link com.baomidou.mybatisplus.core.conditions.query.Query}
@@ -17,14 +26,13 @@ import java.util.function.Predicate;
 @SuppressWarnings("unused")
 public interface Query extends Serializable {
 
-    /**
-     * 设置查询字段
-     *
-     * @param columns 字段数组
-     * @return children
-     */
-    @SuppressWarnings("unchecked")
-     Children select(SFunction... columns);
+
+    List