From a6fb88d74c20cc28043d75e8a5097fce49cf9a78 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 15 十月 2021 15:19:42 +0800
Subject: [PATCH] update [重大更新]全业务 增加 接口文档注解 格式化代码

---
 ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java
index 4bef159..e9c1f19 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java
@@ -1,19 +1,19 @@
 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;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
 import com.baomidou.mybatisplus.core.toolkit.Assert;
-import com.baomidou.mybatisplus.core.toolkit.ClassUtils;
+import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.page.PagePlus;
 import com.ruoyi.common.utils.BeanCopyUtils;
 import com.ruoyi.common.utils.reflect.ReflectUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.ResolvableType;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -49,7 +49,7 @@
 		return entityClass;
 	}
 
-	protected Class<T> mapperClass = currentMapperClass();
+	protected Class<M> mapperClass = currentMapperClass();
 
 	protected Class<V> voClass = currentVoClass();
 
@@ -58,22 +58,17 @@
 	}
 
 	@Override
-	protected Class<T> currentMapperClass() {
-		return (Class<T>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(0).getType();
+	protected Class<M> currentMapperClass() {
+		return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0);
 	}
 
 	@Override
 	protected Class<T> currentModelClass() {
-		return (Class<T>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(1).getType();
+		return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1);
 	}
 
 	protected Class<V> currentVoClass() {
-		return (Class<V>) this.getResolvableType().as(ServicePlusImpl.class).getGeneric(2).getType();
-	}
-
-	@Override
-	protected ResolvableType getResolvableType() {
-		return ResolvableType.forClass(ClassUtils.getUserClass(getClass()));
+		return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2);
 	}
 
 	/**
@@ -126,6 +121,9 @@
 	 */
 	@Override
 	public boolean saveAll(Collection<T> entityList) {
+		if (CollUtil.isEmpty(entityList)) {
+			return false;
+		}
 		return baseMapper.insertAll(entityList) == entityList.size();
 	}
 
@@ -134,6 +132,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 +150,12 @@
 				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();
 	}
 

--
Gitblit v1.9.3