疯狂的狮子li
2021-08-30 e54033f4e43b386a492af1cb25b5f539b34eb205
update 优化 saveOrUpdateAll 空列表校验
已修改1个文件
8 ■■■■ 文件已修改
ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.common.core.mybatisplus.core;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
@@ -134,6 +135,9 @@
     */
    @Override
    public boolean saveOrUpdateAll(Collection<T> entityList) {
        if (CollUtil.isEmpty(entityList)) {
            return false;
        }
        TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
        Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
        String keyProperty = tableInfo.getKeyProperty();
@@ -149,10 +153,10 @@
                updateList.add(entity);
            }
        }
        if (updateList.size()>0 && updateBatchById(updateList)) {
        if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) {
            row += updateList.size();
        }
        if (addList.size() > 0) {
        if (CollUtil.isNotEmpty(addList)) {
            row += baseMapper.insertAll(addList);
        }
        return row == entityList.size();