| | |
| | | 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; |
| | |
| | | */ |
| | | @Override |
| | | public boolean saveAll(Collection<T> entityList) { |
| | | if (CollUtil.isEmpty(entityList)) { |
| | | return false; |
| | | } |
| | | return baseMapper.insertAll(entityList) == entityList.size(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @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(); |
| | |
| | | updateList.add(entity); |
| | | } |
| | | } |
| | | if (updateBatchById(updateList)) { |
| | | if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) { |
| | | row += updateList.size(); |
| | | } |
| | | row += baseMapper.insertAll(addList); |
| | | if (CollUtil.isNotEmpty(addList)) { |
| | | row += baseMapper.insertAll(addList); |
| | | } |
| | | return row == entityList.size(); |
| | | } |
| | | |