mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
移除Map代码
This commit is contained in:
parent
d604be19ac
commit
31662a6e9e
@ -60,7 +60,10 @@ public interface MPJBaseMapper<T> extends BaseMapper<T> {
|
|||||||
*
|
*
|
||||||
* @param wrapper joinWrapper
|
* @param wrapper joinWrapper
|
||||||
*/
|
*/
|
||||||
Map<String, Object> selectJoinMap(@Param(Constants.WRAPPER) MPJBaseJoin<T> wrapper);
|
default Map<String, Object> selectJoinMap(@Param(Constants.WRAPPER) MPJBaseJoin<T> wrapper) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return selectJoinOne(Map.class, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连表查询返回记录集合
|
* 连表查询返回记录集合
|
||||||
@ -76,7 +79,10 @@ public interface MPJBaseMapper<T> extends BaseMapper<T> {
|
|||||||
*
|
*
|
||||||
* @param wrapper joinWrapper
|
* @param wrapper joinWrapper
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> selectJoinMaps(@Param(Constants.WRAPPER) MPJBaseJoin<T> wrapper);
|
default List<Map<String, Object>> selectJoinMaps(@Param(Constants.WRAPPER) MPJBaseJoin<T> wrapper) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (List<Map<String, Object>>) ((Object) selectJoinList(Map.class, wrapper));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连表查询返回记录集合并分页
|
* 连表查询返回记录集合并分页
|
||||||
@ -94,6 +100,9 @@ public interface MPJBaseMapper<T> extends BaseMapper<T> {
|
|||||||
*
|
*
|
||||||
* @param wrapper joinWrapper
|
* @param wrapper joinWrapper
|
||||||
*/
|
*/
|
||||||
<P extends IPage<Map<String, Object>>> P selectJoinMapsPage(P page,
|
default <P extends IPage<Map<String, Object>>> P selectJoinMapsPage(P page,
|
||||||
@Param(Constants.WRAPPER) MPJBaseJoin<T> wrapper);
|
@Param(Constants.WRAPPER) MPJBaseJoin<T> wrapper) {
|
||||||
|
//noinspection unchecked,rawtypes
|
||||||
|
return (P) selectJoinPage((IPage) page, Map.class, wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,9 +137,6 @@ public class MPJSqlInjector extends DefaultSqlInjector {
|
|||||||
list.add(new SelectJoinOne(SqlMethod.SELECT_JOIN_ONE.getMethod()));
|
list.add(new SelectJoinOne(SqlMethod.SELECT_JOIN_ONE.getMethod()));
|
||||||
list.add(new SelectJoinList(SqlMethod.SELECT_JOIN_LIST.getMethod()));
|
list.add(new SelectJoinList(SqlMethod.SELECT_JOIN_LIST.getMethod()));
|
||||||
list.add(new SelectJoinPage(SqlMethod.SELECT_JOIN_PAGE.getMethod()));
|
list.add(new SelectJoinPage(SqlMethod.SELECT_JOIN_PAGE.getMethod()));
|
||||||
list.add(new SelectJoinMap(SqlMethod.SELECT_JOIN_MAP.getMethod()));
|
|
||||||
list.add(new SelectJoinMaps(SqlMethod.SELECT_JOIN_MAPS.getMethod()));
|
|
||||||
list.add(new SelectJoinMapsPage(SqlMethod.SELECT_JOIN_MAPS_PAGE.getMethod()));
|
|
||||||
} else {
|
} else {
|
||||||
list.add(new DeleteJoin());
|
list.add(new DeleteJoin());
|
||||||
list.add(new UpdateJoin());
|
list.add(new UpdateJoin());
|
||||||
@ -148,9 +145,6 @@ public class MPJSqlInjector extends DefaultSqlInjector {
|
|||||||
list.add(new SelectJoinOne());
|
list.add(new SelectJoinOne());
|
||||||
list.add(new SelectJoinList());
|
list.add(new SelectJoinList());
|
||||||
list.add(new SelectJoinPage());
|
list.add(new SelectJoinPage());
|
||||||
list.add(new SelectJoinMap());
|
|
||||||
list.add(new SelectJoinMaps());
|
|
||||||
list.add(new SelectJoinMapsPage());
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
package com.github.yulichang.method;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
|
||||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.mapping.SqlSource;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copy {@link com.baomidou.mybatisplus.core.injector.methods.SelectMaps}
|
|
||||||
*
|
|
||||||
* @author yulichang
|
|
||||||
*/
|
|
||||||
public class SelectJoinMap extends MPJAbstractMethod {
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public SelectJoinMap() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public SelectJoinMap(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
|
||||||
SqlMethod sqlMethod = SqlMethod.SELECT_JOIN_MAP;
|
|
||||||
String sql = String.format(sqlMethod.getSql(), sqlFirst(), sqlDistinct(), sqlSelectColumns(tableInfo, true),
|
|
||||||
mpjTableName(tableInfo), sqlAlias(), sqlFrom(), sqlWhereEntityWrapper(true, tableInfo), sqlComment());
|
|
||||||
SqlSource sqlSource = languageDriver.createSqlSource(configuration, removeExtraWhitespaces(sql), modelClass);
|
|
||||||
return this.addSelectMappedStatementForOther(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String sqlComment() {
|
|
||||||
return super.sqlComment() + StringPool.NEWLINE + SqlScriptUtils.convertIf("${ew.unionSql}", String.format("%s != null and (%s instanceof %s)",
|
|
||||||
Constants.WRAPPER, Constants.WRAPPER, MPJBaseJoin.class.getName()), true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.github.yulichang.method;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
|
||||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.mapping.SqlSource;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copy {@link com.baomidou.mybatisplus.core.injector.methods.SelectMaps}
|
|
||||||
*
|
|
||||||
* @author yulichang
|
|
||||||
*/
|
|
||||||
public class SelectJoinMaps extends MPJAbstractMethod {
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public SelectJoinMaps() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public SelectJoinMaps(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
|
||||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
|
||||||
SqlMethod sqlMethod = SqlMethod.SELECT_JOIN_MAPS;
|
|
||||||
String sql = String.format(sqlMethod.getSql(), sqlFirst(), sqlDistinct(), sqlSelectColumns(tableInfo, true),
|
|
||||||
mpjTableName(tableInfo), sqlAlias(), sqlFrom(), sqlWhereEntityWrapper(true, tableInfo), mpjSqlOrderBy(tableInfo), sqlComment());
|
|
||||||
SqlSource sqlSource = languageDriver.createSqlSource(configuration, removeExtraWhitespaces(sql), modelClass);
|
|
||||||
return this.addSelectMappedStatementForOther(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String sqlComment() {
|
|
||||||
return super.sqlComment() + StringPool.NEWLINE + SqlScriptUtils.convertIf("${ew.unionSql}", String.format("%s != null and (%s instanceof %s)",
|
|
||||||
Constants.WRAPPER, Constants.WRAPPER, MPJBaseJoin.class.getName()), true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.github.yulichang.method;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
|
||||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.mapping.SqlSource;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copy {@link com.baomidou.mybatisplus.core.injector.methods.SelectMaps}
|
|
||||||
*
|
|
||||||
* @author yulichang
|
|
||||||
*/
|
|
||||||
public class SelectJoinMapsPage extends MPJAbstractMethod {
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public SelectJoinMapsPage() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public SelectJoinMapsPage(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
|
||||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
|
||||||
SqlMethod sqlMethod = SqlMethod.SELECT_JOIN_MAPS_PAGE;
|
|
||||||
String sql = String.format(sqlMethod.getSql(), sqlFirst(), sqlDistinct(), sqlSelectColumns(tableInfo, true),
|
|
||||||
mpjTableName(tableInfo), sqlAlias(), sqlFrom(), sqlWhereEntityWrapper(true, tableInfo), mpjSqlOrderBy(tableInfo), sqlComment());
|
|
||||||
SqlSource sqlSource = languageDriver.createSqlSource(configuration, removeExtraWhitespaces(sql), modelClass);
|
|
||||||
return this.addSelectMappedStatementForOther(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String sqlComment() {
|
|
||||||
return super.sqlComment() + StringPool.NEWLINE + SqlScriptUtils.convertIf("${ew.unionSql}", String.format("%s != null and (%s instanceof %s)",
|
|
||||||
Constants.WRAPPER, Constants.WRAPPER, MPJBaseJoin.class.getName()), true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.yulichang.method;
|
package com.github.yulichang.method;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -9,6 +11,7 @@ import java.util.stream.Collectors;
|
|||||||
* @see com.baomidou.mybatisplus.core.enums.SqlMethod
|
* @see com.baomidou.mybatisplus.core.enums.SqlMethod
|
||||||
* @since 2021/1/15
|
* @since 2021/1/15
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum SqlMethod {
|
public enum SqlMethod {
|
||||||
/**
|
/**
|
||||||
* 连表查询
|
* 连表查询
|
||||||
@ -22,18 +25,9 @@ public enum SqlMethod {
|
|||||||
SELECT_JOIN_LIST("selectJoinList", "返回List集合",
|
SELECT_JOIN_LIST("selectJoinList", "返回List集合",
|
||||||
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s %s\n</script>"),
|
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s %s\n</script>"),
|
||||||
|
|
||||||
SELECT_JOIN_MAP("selectJoinMap", "返回一个Map",
|
|
||||||
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s\n</script>"),
|
|
||||||
|
|
||||||
SELECT_JOIN_MAPS("selectJoinMaps", "返回Map集合",
|
|
||||||
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s %s\n</script>"),
|
|
||||||
|
|
||||||
SELECT_JOIN_PAGE("selectJoinPage", "连表查询并分页",
|
SELECT_JOIN_PAGE("selectJoinPage", "连表查询并分页",
|
||||||
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s %s\n</script>"),
|
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s %s\n</script>"),
|
||||||
|
|
||||||
SELECT_JOIN_MAPS_PAGE("selectJoinMapsPage", "返回Map集合并分页",
|
|
||||||
"<script>\n%s SELECT %s %s FROM %s %s %s %s %s %s\n</script>"),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连表删除
|
* 连表删除
|
||||||
*/
|
*/
|
||||||
@ -64,15 +58,6 @@ public enum SqlMethod {
|
|||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getSql() {
|
|
||||||
return sql;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static final List<String> collect = Arrays.stream(SqlMethod.values()).map(SqlMethod::getMethod).collect(Collectors.toList());
|
public static final List<String> collect = Arrays.stream(SqlMethod.values()).map(SqlMethod::getMethod).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user