重命名selectBatchIds方法为selectByIds.
This commit is contained in:
parent
a35bd4322a
commit
151a7d53e5
@ -1,4 +1,4 @@
|
|||||||
APP_VERSION=3.5.7
|
APP_VERSION=3.5.8-SNAPSHOT
|
||||||
APP_GROUP=com.baomidou
|
APP_GROUP=com.baomidou
|
||||||
signing.keyId=1FD337F9
|
signing.keyId=1FD337F9
|
||||||
signing.password=243194995
|
signing.password=243194995
|
||||||
|
@ -78,7 +78,15 @@ public enum SqlMethod {
|
|||||||
SELECT_BY_ID("selectById", "根据ID 查询一条数据", "SELECT %s FROM %s WHERE %s=#{%s} %s"),
|
SELECT_BY_ID("selectById", "根据ID 查询一条数据", "SELECT %s FROM %s WHERE %s=#{%s} %s"),
|
||||||
@Deprecated
|
@Deprecated
|
||||||
SELECT_BY_MAP("selectByMap", "根据columnMap 查询一条数据", "<script>SELECT %s FROM %s %s\n</script>"),
|
SELECT_BY_MAP("selectByMap", "根据columnMap 查询一条数据", "<script>SELECT %s FROM %s %s\n</script>"),
|
||||||
|
/**
|
||||||
|
* @deprecated 3.5.8 {@link #SELECT_BY_IDS}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
SELECT_BATCH_BY_IDS("selectBatchIds", "根据ID集合,批量查询数据", "<script>SELECT %s FROM %s WHERE %s IN (%s) %s </script>"),
|
SELECT_BATCH_BY_IDS("selectBatchIds", "根据ID集合,批量查询数据", "<script>SELECT %s FROM %s WHERE %s IN (%s) %s </script>"),
|
||||||
|
/**
|
||||||
|
* @since 3.5.8
|
||||||
|
*/
|
||||||
|
SELECT_BY_IDS("selectByIds", "根据ID集合,批量查询数据", "<script>SELECT %s FROM %s WHERE %s IN (%s) %s </script>"),
|
||||||
@Deprecated
|
@Deprecated
|
||||||
SELECT_ONE("selectOne", "查询满足条件一条数据", "<script>%s SELECT %s FROM %s %s %s\n</script>"),
|
SELECT_ONE("selectOne", "查询满足条件一条数据", "<script>%s SELECT %s FROM %s %s %s\n</script>"),
|
||||||
SELECT_COUNT("selectCount", "查询满足条件总记录数", "<script>%s SELECT COUNT(%s) AS total FROM %s %s %s\n</script>"),
|
SELECT_COUNT("selectCount", "查询满足条件总记录数", "<script>%s SELECT COUNT(%s) AS total FROM %s %s %s\n</script>"),
|
||||||
|
@ -51,7 +51,7 @@ public class DefaultSqlInjector extends AbstractSqlInjector {
|
|||||||
.add(new DeleteByIds())
|
.add(new DeleteByIds())
|
||||||
.add(new UpdateById())
|
.add(new UpdateById())
|
||||||
.add(new SelectById())
|
.add(new SelectById())
|
||||||
.add(new SelectBatchByIds());
|
.add(new SelectByIds());
|
||||||
} else {
|
} else {
|
||||||
logger.warn(String.format("%s ,Not found @TableId annotation, Cannot use Mybatis-Plus 'xxById' Method.",
|
logger.warn(String.format("%s ,Not found @TableId annotation, Cannot use Mybatis-Plus 'xxById' Method.",
|
||||||
tableInfo.getEntityType()));
|
tableInfo.getEntityType()));
|
||||||
|
@ -15,40 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.baomidou.mybatisplus.core.injector.methods;
|
package com.baomidou.mybatisplus.core.injector.methods;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
|
||||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.mapping.SqlSource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID集合,批量查询数据
|
* 根据ID集合,批量查询数据
|
||||||
*
|
*
|
||||||
* @author hubin
|
* @author hubin
|
||||||
* @since 2018-04-06
|
* @since 2018-04-06
|
||||||
|
* @deprecated 3.5.8 {@link SelectByIds}
|
||||||
*/
|
*/
|
||||||
public class SelectBatchByIds extends AbstractMethod {
|
@Deprecated
|
||||||
|
public class SelectBatchByIds extends SelectByIds {
|
||||||
|
|
||||||
public SelectBatchByIds() {
|
|
||||||
this(SqlMethod.SELECT_BATCH_BY_IDS.getMethod());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name 方法名
|
|
||||||
* @since 3.5.0
|
|
||||||
*/
|
|
||||||
public SelectBatchByIds(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
|
||||||
SqlMethod sqlMethod = SqlMethod.SELECT_BATCH_BY_IDS;
|
|
||||||
SqlSource sqlSource = super.createSqlSource(configuration, String.format(sqlMethod.getSql(),
|
|
||||||
sqlSelectColumns(tableInfo, false), tableInfo.getTableName(), tableInfo.getKeyColumn(),
|
|
||||||
SqlScriptUtils.convertForeach("#{item}", COLL, null, "item", COMMA),
|
|
||||||
tableInfo.getLogicDeleteSql(true, true)), Object.class);
|
|
||||||
return addSelectMappedStatementForTable(mapperClass, methodName, sqlSource, tableInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011-2024, baomidou (jobob@qq.com).
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.baomidou.mybatisplus.core.injector.methods;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
||||||
|
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
||||||
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
|
import org.apache.ibatis.mapping.SqlSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID集合,批量查询数据
|
||||||
|
*
|
||||||
|
* @author hubin
|
||||||
|
* @since 2018-04-06
|
||||||
|
*/
|
||||||
|
public class SelectByIds extends AbstractMethod {
|
||||||
|
|
||||||
|
public SelectByIds() {
|
||||||
|
this(SqlMethod.SELECT_BY_IDS.getMethod());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name 方法名
|
||||||
|
* @since 3.5.0
|
||||||
|
*/
|
||||||
|
public SelectByIds(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
||||||
|
SqlMethod sqlMethod = SqlMethod.SELECT_BY_IDS;
|
||||||
|
SqlSource sqlSource = super.createSqlSource(configuration, String.format(sqlMethod.getSql(),
|
||||||
|
sqlSelectColumns(tableInfo, false), tableInfo.getTableName(), tableInfo.getKeyColumn(),
|
||||||
|
SqlScriptUtils.convertForeach("#{item}", COLL, null, "item", COMMA),
|
||||||
|
tableInfo.getLogicDeleteSql(true, true)), Object.class);
|
||||||
|
return addSelectMappedStatementForTable(mapperClass, methodName, sqlSource, tableInfo);
|
||||||
|
}
|
||||||
|
}
|
@ -253,17 +253,40 @@ public interface BaseMapper<T> extends Mapper<T> {
|
|||||||
* 查询(根据ID 批量查询)
|
* 查询(根据ID 批量查询)
|
||||||
*
|
*
|
||||||
* @param idList 主键ID列表(不能为 null 以及 empty)
|
* @param idList 主键ID列表(不能为 null 以及 empty)
|
||||||
|
* @return 数据列表
|
||||||
*/
|
*/
|
||||||
List<T> selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList);
|
List<T> selectByIds(@Param(Constants.COLL) Collection<? extends Serializable> idList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据ID 批量查询)
|
||||||
|
*
|
||||||
|
* @param idList 主键ID列表(不能为 null 以及 empty)
|
||||||
|
* @return 数据列表
|
||||||
|
* @deprecated 3.5.8
|
||||||
|
*/
|
||||||
|
default List<T> selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList) {
|
||||||
|
return selectByIds(idList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询(根据ID 批量查询)
|
* 查询(根据ID 批量查询)
|
||||||
*
|
*
|
||||||
* @param idList idList 主键ID列表(不能为 null 以及 empty)
|
* @param idList idList 主键ID列表(不能为 null 以及 empty)
|
||||||
* @param resultHandler resultHandler 结果处理器 {@link ResultHandler}
|
* @param resultHandler resultHandler 结果处理器 {@link ResultHandler}
|
||||||
* @since 3.5.4
|
* @since 3.5.8
|
||||||
*/
|
*/
|
||||||
void selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList, ResultHandler<T> resultHandler);
|
void selectByIds(@Param(Constants.COLL) Collection<? extends Serializable> idList, ResultHandler<T> resultHandler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param idList idList 主键ID列表(不能为 null 以及 empty)
|
||||||
|
* @param resultHandler resultHandler 结果处理器 {@link ResultHandler}
|
||||||
|
* @since 3.5.4
|
||||||
|
* @deprecated 3.5.8
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default void selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList, ResultHandler<T> resultHandler) {
|
||||||
|
selectByIds(idList, resultHandler);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询(根据 columnMap 条件)
|
* 查询(根据 columnMap 条件)
|
||||||
|
@ -306,7 +306,7 @@ public interface IService<T> {
|
|||||||
* @param idList 主键ID列表
|
* @param idList 主键ID列表
|
||||||
*/
|
*/
|
||||||
default List<T> listByIds(Collection<? extends Serializable> idList) {
|
default List<T> listByIds(Collection<? extends Serializable> idList) {
|
||||||
return getBaseMapper().selectBatchIds(idList);
|
return getBaseMapper().selectByIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -301,7 +301,7 @@ public class Db {
|
|||||||
* @param entityClass 实体类
|
* @param entityClass 实体类
|
||||||
*/
|
*/
|
||||||
public static <T> List<T> listByIds(Collection<? extends Serializable> idList, Class<T> entityClass) {
|
public static <T> List<T> listByIds(Collection<? extends Serializable> idList, Class<T> entityClass) {
|
||||||
return SqlHelper.execute(entityClass, baseMapper -> baseMapper.selectBatchIds(idList));
|
return SqlHelper.execute(entityClass, baseMapper -> baseMapper.selectByIds(idList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -932,7 +932,7 @@ class H2UserTest extends BaseTest {
|
|||||||
System.out.println(resultObject);
|
System.out.println(resultObject);
|
||||||
});
|
});
|
||||||
System.out.println("---------------selectBatchIds-------------------");
|
System.out.println("---------------selectBatchIds-------------------");
|
||||||
baseMapper.selectBatchIds(ids, resultContext -> System.out.println(resultContext.getResultObject()));
|
baseMapper.selectByIds(ids, resultContext -> System.out.println(resultContext.getResultObject()));
|
||||||
System.out.println("---------------selectList-------------------");
|
System.out.println("---------------selectList-------------------");
|
||||||
System.out.println("---------------selectObjs-------------------");
|
System.out.println("---------------selectObjs-------------------");
|
||||||
baseMapper.selectObjs(Wrappers.emptyWrapper(), (ResultHandler<Long>) resultContext -> System.out.println(resultContext.getResultObject()));
|
baseMapper.selectObjs(Wrappers.emptyWrapper(), (ResultHandler<Long>) resultContext -> System.out.println(resultContext.getResultObject()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user