mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
Merge branch 'main' of https://gitee.com/mybatis-flex/mybatis-flex
This commit is contained in:
commit
065a15ebf1
@ -141,6 +141,28 @@ public interface BaseMapper<T> {
|
||||
@DeleteProvider(type = EntitySqlProvider.class, method = "deleteBatchByIds")
|
||||
int deleteBatchByIds(@Param(FlexConsts.PRIMARY_VALUE) Collection<? extends Serializable> ids);
|
||||
|
||||
/**
|
||||
* 根据多个 id 批量删除数据
|
||||
*
|
||||
* @param ids ids 列表
|
||||
* @param size 切分大小
|
||||
* @return 返回影响的行数
|
||||
* @see com.mybatisflex.core.provider.EntitySqlProvider#deleteBatchByIds(Map, ProviderContext)
|
||||
*/
|
||||
default int deleteBatchByIds(@Param(FlexConsts.PRIMARY_VALUE) List<? extends Serializable> ids, int size) {
|
||||
if (size <= 0) {
|
||||
size = 1000;//默认1000
|
||||
}
|
||||
int sum = 0;
|
||||
int entitiesSize = ids.size();
|
||||
int maxIndex = entitiesSize / size + (entitiesSize % size == 0 ? 0 : 1);
|
||||
for (int i = 0; i < maxIndex; i++) {
|
||||
List<? extends Serializable> list = ids.subList(i * size, Math.min(i * size + size, entitiesSize));
|
||||
sum += deleteBatchByIds(list);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据 map 构建的条件来删除数据
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user